简体   繁体   中英

What is the ERR! code ENOLOCAL npm ERR! Could not install from error?

I am going to update npm latest version, but it's showing this error message,

G:\>npm i -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\hemanth\AppData\Roaming\npm-cache\_logs\2018-01-08T03_34_29_774Z-debug.log

G:\>

在此处输入图片说明

This is an issue in node which is caused by white space in your windows username (possibly between the first-name and last-name in windows).

run the following command after replacing firstname with your windows user firstname in command prompt with administrator access

npm config set cache "C:\Users\Firstname~1\AppData\Roaming\npm-cache" --global

This worked for me:

npm cache verify

Then I re-ran:

npm install -g create-react-app

And it installed like as expected: Issue resolved

终端输出截图

I got same issue because I was using an updated "package-lock.json" file from another system, and there was no "node_modules" folder on system where I got the problem.

You can try to following:

  1. Move "package-lock.json" to some other folder, outside current directory.
  2. npm install

If you are facing with this issue, first you should update npm using the below code:

npm -g install npm

then try to create the React file. It is working 100% for me.

Run CMD in administrator mode and fire below commands in order

  1. Run cmd as administrator
  2. Run npm config edit (You will get notepad editor)
  3. Change prefix variable to C:\\Users\\AppData\\Roaming\\npm
  4. npm install -g create-react-app Go to the link for more npm - EPERM: operation not permitted on Windows Thanks.

I got error npm ERR! code ENOLOCAL while running npx create-react-app my-app uninstall and install is worked for me… npm uninstall -g create-react-app

npm install -g create-react-app this will upgrade your npx, then run npx create-react-app my-app this works fine

npm cache verify
npm install -g create-react-app

This worked for me:

npm install -g degit

is like an upgrade

Please verify, whether your npm has installed create-react-app in **%AppData%Roaming\\npm\\node_modules**

if not then install it by using the command

npm install -g create-react-app

I am going to update npm latest version, but it's showing this error message,

G:\>npm i -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\hemanth\AppData\Roaming\npm-cache\_logs\2018-01-08T03_34_29_774Z-debug.log

G:\>

在此处输入图片说明

In the latest Windows, the firewall will block the node.exe to create package.json. So turn off the firewall settings and try once, It worked for me.

I got the same problem while trying to use sevelte with the command

npx degit sveltejs/template youproject

The following was useful:

install -g degit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM