呃!代码ENOLOCAL npm ERR!无法安装

Hem*_*mar 7 windows json npm angular

我将更新npm最新版本但是它显示此错误消息,帮我解决这个问题谢谢..

G:> npm i -g npm ERR!代码ENOLOCAL npm ERR!无法从""安装,因为它不包含package.json文件.

错误的ERR!可以在以下位置找到此运行的完整日志:npm ERR!
C:\ Users\hemanth\AppData\Roaming \npm-cache_logs\2018-01-08T03_34_2 9_774Z-debug.log

G:>

在此输入图像描述

小智 47

这是 node 中的一个问题,它是由 Windows 用户名中的空格引起的(可能在 Windows 中的名字和姓氏之间)。

在具有管理员访问权限的命令提示符中将 firstname 替换为 Windows 用户 firstname 后运行以下命令

npm config set cache "C:\Users\Firstname~1\AppData\Roaming\npm-cache" --global
Run Code Online (Sandbox Code Playgroud)


Hem*_*mar 10

这对我有用:

npm cache verify
Run Code Online (Sandbox Code Playgroud)

然后我重新跑了:

npm install -g create-react-app
Run Code Online (Sandbox Code Playgroud)

并按预期安装:问题已解决

终端输出的截图


小智 8

我遇到了同样的问题,因为我使用的是来自另一个系统的更新的“package-lock.json”文件,并且在我遇到问题的系统上没有“node_modules”文件夹。

您可以尝试以下操作:

  1. 将“package-lock.json”移动到当前目录之外的其他文件夹。
  2. 安装


小智 5

如果您遇到此问题,首先应该使用以下代码更新 npm:

npm -g install npm
Run Code Online (Sandbox Code Playgroud)

然后尝试创建 React 文件。它对我来说是 100% 的工作。