简体   繁体   English

错误:尝试运行 npm 时找不到模块“C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js”

[英]Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js' when trying to run npm

I am trying to run npm install from the cmd in a windows environment.我正在尝试在 windows 环境中从 cmd 运行 npm 安装。 The following error occurs:出现以下错误:

internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Is there a reason why \node_modules\npm\bin\ repeats within the file path? \node_modules\npm\bin\ 在文件路径中重复是否有原因? I've set the environmental variables to:我已将环境变量设置为:

C:\Program Files\nodejs\node_modules\npm\bin

and to:并:

C:\Program Files\nodejs\

Is there a solution to fix this issue so that I can run the npm commands?是否有解决此问题的解决方案,以便我可以运行 npm 命令?

Copy the directory named npm from your installed node path (In my case the npm directory was available in C:\\Program Files\\nodejs\\node_modules ).从您安装的节点路径复制名为npm的目录(在我的情况下,npm 目录在C:\\Program Files\\nodejs\\node_modules )。

Navigate to C:\\Users\\%USERNAME%\\AppData\\Roaming\\npm\\node_modules and paste the copied npm directory there.导航到C:\\Users\\%USERNAME%\\AppData\\Roaming\\npm\\node_modules并将复制的 npm 目录粘贴到那里。

this should work.这应该有效。

在终端中运行此行,它应该可以工作;-) 祝你好运!

SET PATH=C:\Program Files\Nodejs;%PATH%

I was getting this error after installing with nvm for Windows: https://github.com/coreybutler/nvm-windows .使用nvm为 Windows 安装后出现此错误: https://github.com/coreybutler/nvm-windows

I just reinstalled Node in Git Bash instead of PowerShell.我刚刚在 Git Bash 而不是 PowerShell 中重新安装了 Node。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:找不到模块 'C:\Users\nguye\AppData\Local\nodejs\node_modules\npm\bin\npm-cli.js' - Error: Cannot find module 'C:\Users\nguye\AppData\Local\nodejs\node_modules\npm\bin\npm-cli.js' 找不到模块 'C:\\node_modules\\npm\\bin\\npm-cli.js - Cannot find module 'C:\node_modules\npm\bin\npm-cli.js 'CALL“ C:\\ Program Files \\ nodejs \\\\ node_modules \\ npm \\ bin \\ npm-cli.js”前缀-g不被识别为内部或外部命令, - 'CALL “C:\Program Files\nodejs\\node_modules \npm\bin\npm-cli.js” prefix -g' is not recognized as an internal or external com mand, EACCES:权限被拒绝,打开'/usr/local/lib/node_modules/npm/bin/npm-cli.js' - EACCES: permission denied, open '/usr/local/lib/node_modules/npm/bin/npm-cli.js' 安装 Drivelist 时找不到模块 'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin' - Cannot find module 'C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin' While installing Drivelist 错误:找不到模块“C:\Users\senyo\AppData\Roaming\npm\node_modules\expo-cli\bin\expo.js” - Error: Cannot find module 'C:\Users\senyo\AppData\Roaming\npm\node_modules\expo-cli\bin\expo.js' NPM node_modules / .bin符号链接 - NPM node_modules/.bin symlinks 节点 Nodemon 错误:找不到模块 'C:\\Program Files\\nodejs\\node_modules\\nodemon\\bin\\' - Node Nodemon Error: Cannot find module 'C:\Program Files\nodejs\node_modules\nodemon\bin\' 安装 npm faker 后出现找不到 \node_modules\cypress\bin\cypress 错误 - Getting cannot find \node_modules\cypress\bin\cypress error after install npm faker 无法运行 npm 脚本,它显示“错误:spawn node_modules/webpack/bin/webpack.js EACCES” - Cant run npm script, it shown “Error: spawn node_modules/webpack/bin/webpack.js EACCES”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM