Nag*_*Nag 23 node.js npm sails.js
我最近升级了我的计算机并使用它升级到最新的Node和NPM的LTS版本:
我有一个Sails.js 0.12.14应用程序,我正在尝试安装NPM依赖项,npm install但当我这样做时,我收到以下错误:
? web-service git:(feature/auth) ? npm install
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/pako-660dbb41/package.json'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/pako-660dbb41/README.md'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/pako-660dbb41/LICENSE'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/pako-660dbb41/index.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/pako-660dbb41/CHANGELOG.md'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/camelCase.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/uniqueId.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/bindKey.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/unnest.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/bindAll.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/unset.js'
// a bunch of similar Lodash errors removed from here
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/T.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/zipWith.js'
WARN tar ENOENT: no such file or directory, open '/Users/Nag/Code/project/web-service/node_modules/.staging/lodash-6e6c9f2a/fp/lastIndexOfFrom.js'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: oauth-sign@0.8.2 (node_modules/oauth-sign):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: Cannot cd into '/Users/Nag/Code/project/web-service/node_modules/.staging/oauth-sign-b13c86db'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: mkdirp@0.5.1 (node_modules/mkdirp):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: Cannot cd into '/Users/Nag/Code/project/web-service/node_modules/.staging/mkdirp-c94c8047'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: minimist@0.0.8 (node_modules/mkdirp/node_modules/minimist):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: Cannot cd into '/Users/Nag/Code/project/web-service/node_modules/.staging/minimist-ba966a6e'
npm ERR! path /Users/Nag/Code/project/web-service/node_modules/.staging/sails-02afd14e/node_modules/@sailshq/body-parser
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/Nag/Code/project/web-service/node_modules/.staging/sails-02afd14e/node_modules/@sailshq/body-parser' -> '/Users/Nag/Code/project/web-service/node_modules/.staging/@sailshq/body-parser-6d1e8405'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Nag/.npm/_logs/2018-01-22T14_40_13_889Z-debug.log
Run Code Online (Sandbox Code Playgroud)
我似乎无法弄清楚发生了什么,也无法在网上找到合适的答案.我甚至跑了npm cache clean --force,rm -rf node_modules并重试了类似的错误.当我在Node~6上似乎工作正常但升级到Node 8.9.4和NPM 5.6.0后,它只是不会安装我的依赖项.我该如何解决这个问题?
小智 39
尝试删除该package-lock.json文件.
小智 15
就我而言,我尝试删除package-lock.json、清除和验证 npm 缓存、删除node_modules、甚至停止防病毒软件(W10 机器),但仍然收到此错误。
我以某种方式通过运行npm updatebefore修复了它npm install,这创建了一个新的package-lock.json:
del /f package-lock.json
rd /s /q node_modules
npm cache clean
npm cache verify
npm update
npm install
Run Code Online (Sandbox Code Playgroud)
对我来说,事实证明这些错误隐藏了真正的潜在问题,即我的第三方 npm 存储库 (azure devops) 的凭据已过期。我不得不重新运行vsts-npm-auth -config .npmrc以更新我.npmrc文件中的令牌。
删除并重新生成“package-lock.json”通常可以解决这个问题,但这本身就有风险,因为您可能一次升级多个包。
在我的例子中,结果是 package-lock.json 引用了一个特定的包版本,在依赖项中有 5 个级别。该版本不再存在于 npm 注册表中,因此导致安装中断。我必须找到哪个包引入了这个依赖项并升级那个包来解决这个问题。
没有许可,没有互联网问题,这只是的一般问题npm。我用纱解决了这个问题。
yarn install
Run Code Online (Sandbox Code Playgroud)
或者您可以使用no-optional标志。
npm install --no-optional
Run Code Online (Sandbox Code Playgroud)
小智 5
删除node_modules
只需删除package-lock.json文件,然后安装你想要的软件包npm install。一切都会奏效。
rm -rf node_modules
rm package-lock.json
npm install
如果问题仍然存在,请检查您是否安装了任何软件包的全局版本。如果您的包的全局版本与包的本地版本发生冲突,则可能会发生这种情况。
当我在 Node.js 12 上尝试运行使用 Node.js 16 生成的代码npm install时,就发生了这种情况。package-lock.json
切换回 Node.js 16 解决了该问题:
nvm use 16
Run Code Online (Sandbox Code Playgroud)
当然,删除package-lock.json也可以解决我的问题。
| 归档时间: |
|
| 查看次数: |
14767 次 |
| 最近记录: |