You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

npm install执行失败:循环调用与命令未识别问题求助

npm install 触发循环调用导致报错

问题场景

执行npm install时,出现循环调用npm i的情况,最终提示'npm' is not recognized as an internal or external command。

package.json 配置

{
  "name": "bundle",
  "version": "1.0.0",
  "description": "",
  "main": "webpack.config.js",
  "author": "",
  "license": "ISC",
  "scripts": {
    "install": "npm i",
    "bundle": "webpack",
    "watch": "webpack --mode=development --watch"
  },
  "devDependencies": {
    "@babel/plugin-transform-runtime": "^7.19.6",
    "@babel/preset-env": "^7.20.2",
    "@babel/preset-react": "^7.18.6",
    "@babel/preset-typescript": "^7.18.6",
    "@types/react": "^18.0.25",
    "@types/react-dom": "^18.0.8",
    "babel-loader": "^9.1.0",
    "css-loader": "^6.7.1",
    "html-webpack-plugin": "^5.5.0",
    "sass": "^1.56.0",
    "sass-loader": "^13.1.0",
    "source-map-loader": "^4.0.1",
    "style-loader": "^3.3.1",
    "ts-loader": "^9.4.1",
    "typescript": "^4.8.4",
    "webpack": "^5.74.0",
    "webpack-cli": "^4.10.0"
  },
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
}

报错信息

> bundle@1.0.0 install
> npm i

> bundle@1.0.0 install
> npm i

> bundle@1.0.0 install
> npm i

> bundle@1.0.0 install
> npm i

> bundle@1.0.0 install
> npm i

> bundle@1.0.0 install
> npm i

> bundle@1.0.0 install
> npm i

> bundle@1.0.0 install
> npm i

'npm' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_35_56_965Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_35_56_990Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_35_57_010Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_35_57_032Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i

VS 2022 运行日志

0 verbose cli [
0 verbose cli   'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\VisualStudio\\NodeJs\\node.exe',
0 verbose cli   'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\VisualStudio\\NodeJs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'prefix',
0 verbose cli   '-g'
0 verbose cli ]
1 info using npm@8.3.1
2 info using node@v16.14.0
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VisualStudio\NodeJs\node_modules\npm\npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 1ms
9 timing config:load:project Completed in 0ms
10 timing config:load:file:C:\Users\Niklas\.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VisualStudio\NodeJs\etc\npmrc Completed in 0ms
13 timing config:load:global Completed in 1ms
14 timing config:load:validate Completed in 0ms
15 timing config:load:credentials Completed in 0ms
16 timing config:load:setEnvs Completed in 1ms
17 timing config:load Completed in 6ms
18 timing npm:load:configload Completed in 6ms
19 timing npm:load:setTitle Completed in 0ms
20 timing config:load:flatten Completed in 2ms
21 timing npm:load:display Completed in 2ms
22 verbose logfile C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_17_05_361Z-debug-0.log
23 timing npm:load:logFile Completed in 4ms
24 timing npm:load:timers Completed in 0ms
25 timing npm:load:configScope Completed in 0ms
26 timing npm:load Completed in 13ms
27 timing command:prefix Completed in 1ms
28 verbose exit 0
29 timing npm Completed in 171ms
30 info ok

已尝试的解决方法

  • 卸载并重装不同版本的 Node.js/npm
  • 清除 npm 缓存
  • 删除所有 npm 相关文件夹后重启电脑

以上操作均未解决问题,寻求帮助。


内容的提问来源于stack exchange,提问作者Sensei Munk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 06:31:11