首页 > 解决方案 > 'npm install -g' 找不到 'Roaming\npm\node_modules\' 目录

问题描述

我刚刚将 nodejs 下载并安装到我的新机器上,但“npm install -g”和“npm install”命令都不起作用。它给出了 ENOENT 错误。我检查了全局安装包的路径,即“C:\Users\USER\AppData\Roaming\npm\node_modules”文件夹,错误提示找不到“lib”或“bin”文件夹,但所有文件夹由命令缺少第一个字母。尝试全局安装 typescript 时,会显示我在下面遇到的 npm 错误。我似乎找不到解决方案,有人知道我该怎么办吗?提前致谢。

npm WARN tar ENOENT: no such file or directory, open 'C:\Users\USER\AppData\Roaming\npm\node_modules\.staging\typescript-21dd751b\bin\tsc'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\USER\AppData\Roaming\npm\node_modules\.staging\typescript-21dd751b\bin\tsserver'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\USER\AppData\Roaming\npm\node_modules\.staging\typescript-21dd751b\lib\cancellationToken.js'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\USER\AppData\Roaming\npm\node_modules\.staging\typescript-21dd751b\lib\cs\diagnosticMessages.generated.json'
npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://npm.community>

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\USER\AppData\Roaming\npm-cache\_logs\2019-11-12T12_33_04_656Z-debug.log

查看文件夹的屏幕截图

标签: javascriptnode.jsnpm

解决方案


推荐阅读