2016-02-05 120 views
0

npm开发者文档通过运行npm install -g .来说make sure your package installs globally before publishing。我试图构建一个可以全局安装并运行的ES6 CLI包,但在运行Babel进行传输(使用es2015插件)后,我的机器上的全局安装失败。npm install -g。不复制,失败

I've created a simple demo ES6 project that reproduces the error。克隆和运行npm install -g .在自述文件中引发错误:

$ npm install -g . 

> [email protected] prepublish /Users/me/dev/es6-test 
> npm run build 


> [email protected] build /Users/me/dev/es6-test 
> babel --out-dir es5/ src/ 

src/bin/app.js -> es5/bin/app.js 
src/core/location.js -> es5/core/location.js 
npm ERR! Darwin 14.5.0 
npm ERR! argv "/usr/local/Cellar/node/5.4.0/bin/node" "/usr/local/bin/npm" "install" "-g" "." 
npm ERR! node v5.4.0 
npm ERR! npm v3.3.12 
npm ERR! path /usr/local/lib/node_modules/es6-test/es5/bin/app 
npm ERR! code ENOENT 
npm ERR! errno -2 
npm ERR! syscall chmod 

npm ERR! enoent ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/es6-test/es5/bin/app' 
npm ERR! enoent This is most likely not a problem with npm itself 
npm ERR! enoent and is related to npm not being able to find a file. 
npm ERR! enoent 

npm ERR! Please include the following file with any support request: 
npm ERR!  /Users/me/dev/es6-test/npm-debug.log 

我做错了什么?我已经尝试了几个不同的命令,包括Babel和NPM,但最终没有任何东西被复制到/usr/local/lib/node_modules

$ node -v 
v5.4.0 

$ npm -v 
3.3.12 

编辑:此错误似乎与最新的节点和v0.10.24一样的,有和没有sudo。日志文件说:

0 info it worked if it ends with ok 
1 verbose cli [ '/usr/local/Cellar/node/5.4.0/bin/node', 
1 verbose cli '/usr/local/bin/npm', 
1 verbose cli 'i', 
1 verbose cli '-g', 
1 verbose cli '.gs' ] 
2 info using [email protected] 
3 info using [email protected] 
4 silly loadCurrentTree Starting 
5 silly install loadCurrentTree 
6 silly install readGlobalPackageData 
7 silly fetchPackageMetaData .gs 
8 silly fetchOtherPackageData .gs 
9 silly cache add args [ '.gs', null ] 
10 verbose cache add spec .gs 
11 silly cache add parsed spec Result { 
11 silly cache add raw: '.gs', 
11 silly cache add scope: null, 
11 silly cache add name: null, 
11 silly cache add rawSpec: '.gs', 
11 silly cache add spec: '/Users/me/dev/es6-test/.gs', 
11 silly cache add type: 'local' } 
12 error addLocal Could not install /Users/me/dev/es6-test/.gs 
13 silly fetchPackageMetaData Error: ENOENT: no such file or directory, open '/Users/me/dev/es6-test/.gs' 
13 silly fetchPackageMetaData  at Error (native) 
13 silly fetchPackageMetaData error for .gs { [Error: ENOENT: no such file or directory, open '/Users/me/dev/es6-test/.gs'] 
13 silly fetchPackageMetaData errno: -2, 
13 silly fetchPackageMetaData code: 'ENOENT', 
13 silly fetchPackageMetaData syscall: 'open', 
13 silly fetchPackageMetaData path: '/Users/me/dev/es6-test/.gs' } 
14 silly rollbackFailedOptional Starting 
15 silly rollbackFailedOptional Finishing 
16 silly runTopLevelLifecycles Starting 
17 silly runTopLevelLifecycles Finishing 
18 silly install printInstalled 
19 verbose stack Error: ENOENT: no such file or directory, open '/Users/me/dev/es6-test/.gs' 
19 verbose stack  at Error (native) 
20 verbose cwd /Users/me/dev/es6-test 
21 error Darwin 14.5.0 
22 error argv "/usr/local/Cellar/node/5.4.0/bin/node" "/usr/local/bin/npm" "i" "-g" ".gs" 
23 error node v5.4.0 
24 error npm v3.3.12 
25 error path /Users/me/dev/es6-test/.gs 
26 error code ENOENT 
27 error errno -2 
28 error syscall open 
29 error enoent ENOENT: no such file or directory, open '/Users/me/dev/es6-test/.gs' 
29 error enoent This is most likely not a problem with npm itself 
29 error enoent and is related to npm not being able to find a file. 
30 verbose exit [ -2, true ] 
+0

去根(项目),然后使用sudo调用它,还要设置您的NPM-文件的debug.log路径, 给予许可。 – Monty

+0

'sudo'似乎没有区别。我应该在哪些文件上设置什么权限?我附加了npm日志文件输出。 – orlade

回答

1

package.json点的"bin"属性设置为一个app.js文件es5/bin但没有app.js文件。你需要把它指向的csp.js文件:

的package.json

"bin": { 
    "csp": "es5/bin/csp.js" 
}, 
+0

对,对不起,我忘了重命名,但不幸的是它并没有帮助。我已将它更改为'app.js',但它是相同的错误。 – orlade

+0

我的意思是你应该把它改成'csp.js'。我已经使用您创建的回购测试过了。 – gnerkus

+0

我的意思是我将'csp'的所有实例更改为'app',包括在包中。 'csp'是我正在研究的其他东西,但是对于所有的意图和目的来说,只要所有命名一致,就是一样的。我现在已经修复了回购协议,它仍然是一样的(也更新了上面的日志)。 – orlade