执行“ng new”命令时出现 NPM 错误

时间:2021-05-15 14:56:40

标签: node.js npm

我正在运行以下命令 (windows) (npm v7.0.0-beta.8) (node v12.18.1)

ng new light-webapp

它抛出以下错误

...
CREATE light-webapp/e2e/tsconfig.json (299 bytes)
CREATE light-webapp/e2e/src/app.e2e-spec.ts (645 bytes)
CREATE light-webapp/e2e/src/app.po.ts (301 bytes)
| Installing packages...npm ERR! code ERESOLVE
npm ERR! unable to resolve dependency tree

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\...\AppData\Local\npm-cache\_logs\2021-05-15T14_51_21_350Z-debug.log
× Package install failed, see above.
The Schematic workflow failed. See above.

上面提到的错误日志显示如下:

...
1899 timing idealTree:node_modules/karma-jasmine Completed in 0ms
1900 silly placeDep jasmine-core@>=3.7.1 Symbol(CONFLICT) for: karma-jasmine-html-reporter@1.6.0
1901 timing idealTree Completed in 15783ms
1902 timing command:install Completed in 15789ms
1903 verbose type peer
1904 verbose stack Error: unable to resolve dependency tree
1904 verbose stack     at Arborist.[placeDep] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:814:27)
1904 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:631:46
1904 verbose stack     at Array.map (<anonymous>)
1904 verbose stack     at Arborist.[buildDepStep] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:631:8)
1904 verbose stack     at async Arborist.buildIdealTree (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:166:7)
1904 verbose stack     at async Promise.all (index 1)
1904 verbose stack     at async Arborist.reify (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:125:5)
1904 verbose stack     at async install (C:\Program Files\nodejs\node_modules\npm\lib\install.js:40:5)
1905 verbose cwd C:\Users\...\VisualStudioCodeWorkspace\light-webapp
1906 verbose Windows_NT 10.0.18363
1907 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--quiet"
1908 verbose node v12.18.1
1909 verbose npm  v7.0.0-beta.8
1910 error code ERESOLVE
1911 error unable to resolve dependency tree

知道为什么节点在这么简单的命令上失败了吗?

1 个答案:

答案 0 :(得分:0)

分别安装最新版本的 node 和 npm 解决了我的问题。