$ node -v
v8.11.1
和npm
$ npm -v
v5.6.0
当我尝试全局安装npm时,它给了我这个错误:
$ npm install -g
npm ERR! code ENOLOCAL
npm ERR! Could not install from "" as it does not contain a package.json
file.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Aroma\AppData\Roaming\npm-cache\_logs\2018-04-
07T11_10_29_184Z-debug.log
甚至当我尝试将其本地安装到存储库时,它已经给了我:
$ npm install
npm WARN saveError ENOENT: no such file or directory, open
'C:\Users\Aroma\Desktop\app\package.json'
npm notice created a lockfile as package-lock.json. You should commit this
file.
npm WARN enoent ENOENT: no such file or directory, open
'C:\Users\Aroma\Desktop\app\package.json'
npm WARN app No description
npm WARN app No repository field.
npm WARN app No README data
npm WARN app No license field.
up to date in 0.11s
任何帮助将不胜感激
答案 0 :(得分:0)
请尝试使用以下命令更改npm版本:
npm -g install npm@4.2.0
在此问题上对我有用。
答案 1 :(得分:0)
我遇到了同样的问题。 我所做的是通过以下方式重命名package-lock.json:
mv package-lock.json package.json
,然后应解决此问题。
如果出现下一则显示消息的问题: [...] / rollbackFailedOptional:动词npm-session xxxxxxxxxxx ,那么你可以做
这些步骤对我有用。 希望他们也能对您有所帮助。
答案 2 :(得分:0)
我有同样的问题。我以这种方式解决了。
步骤1:以管理员身份打开命令提示符,然后运行 npm install -g create-react-app 解决npx问题。
第2步:运行 npx create-react-app您的应用名称