我尝试在我下载的 angular 项目中安装 node_module,但出现此错误:
npm 错误!注册表错误解析json
然后我重新安装 npm 使用npm intall npm -g,然后当我尝试使用时出现npm install此错误:
(node:11252) UnhandledPromiseRejectionWarning: Unhandled promise
rejection (rejection id: 1): Error: ENOENT: no such file or directory, stat
'C:\Users\User\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-ec5da46c\angular\cdk.es5.js'
Run Code Online (Sandbox Code Playgroud)
调试日志:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install' ]
2 info using npm@5.4.2
3 info using node@v6.10.2
4 verbose npm-session ff5ce249dfe37f0e
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall spa@0.0.0
7 info lifecycle spa@0.0.0~preinstall: spa@0.0.0
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 silly install loadShrinkwrap
13 info lifecycle @angular/cdk@2.0.0-beta.10-a7ce31e~prepack: @angular/cdk@2.0.0-beta.10-a7ce31e
14 error cb() never called!
15 error This is an error with npm itself. Please report this error at:
16 error <https://github.com/npm/npm/issues>
Run Code Online (Sandbox Code Playgroud)
我已经试过了,npm cache clean --force但我得到了同样的错误。
node -v v6.10.2
npm -v 5.4.2
Run Code Online (Sandbox Code Playgroud)
我遇到过同样的问题。我解决了
通过排除 package-lock.json 文件
npm i --no-package-lock
Run Code Online (Sandbox Code Playgroud)
或者通过手动删除 package-lock.json
确保package.json您的角度项目的根目录中有一个文件,其外观应与此类似。
https://github.com/heroku/node-js-sample/blob/master/package.json
如果 package.json 文件存在,您可以运行npm install以获取保存到其中的包,这将为node_modules您生成一个目录。
但是,如果该文件不存在,则意味着您必须通过运行将 npm 初始化到项目中,npm i -y这将自动为您创建 package.json 文件,并允许您安装节点模块。
注意:您的机器上已经安装了 npm,因此运行npm install npm -g并不理想。
| 归档时间: |
|
| 查看次数: |
17550 次 |
| 最近记录: |