gpt4 book ai didi

javascript - npm install -g 。不复制,失败

转载 作者:行者123 更新时间:2023-12-03 07:45:32 24 4
gpt4 key购买 nike

npm 开发人员文档说 make sure your package installs globally before publishing通过运行npm install -g .。我正在尝试构建一个可以全局安装和运行的 ES6 CLI 包,但是在运行 Babel 对其进行转译(使用 es2015 插件)后,我的计算机上的全局安装失败。

I've created a simple demo ES6 project that reproduces the error 。克隆并运行 npm install -g . 会在 README 中抛出错误:

$ npm install -g .

> es6-test@0.0.1 prepublish /Users/me/dev/es6-test
> npm run build


> es6-test@0.0.1 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

编辑:无论有没有 sudo,最新 Node 和 v0.10.24 的错误似乎都是相同的。日志文件显示:

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 npm@3.3.12
3 info using node@v5.4.0
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 ]

最佳答案

package.json"bin" 属性指向 es5/bin 中的 app.js 文件code> 但没有 app.js 文件。您需要将其指向 csp.js 文件:

package.json

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

关于javascript - npm install -g 。不复制,失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35223755/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com