30

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:\>

Error

Noam Yizraeli
  • 4,446
  • 18
  • 35
Hemanth Kumar
  • 809
  • 1
  • 7
  • 7
  • I was typing `-create-react-native-app` instead of `create-react-app` and it was the cause of my problem. – Shahriar Sep 17 '18 at 14:25

12 Answers12

69

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
Matthew Lock
  • 13,144
  • 12
  • 92
  • 130
makeshnaidu2011
  • 691
  • 5
  • 5
  • 1
    I've had issues all the time due to my name folder having a space in it. I'm excited to see if I can utilize this solution to resolve issues with other tools as well (Rust, etc). Cheers! – Zach Dahl Mar 05 '21 at 16:20
  • 1
    Amazing, the solution worked immediately. Thanks! – Chris - Jr May 23 '21 at 19:50
  • Not that it looks like it's not always "Firstname~1" in that path. I needed to leave out the last letter of my first name: "Firstnam~1" (no, that's not my real name). – Lmbrtz Jun 09 '21 at 09:10
  • This solution works just fine, thanks a lot. – Rene Arteaga Aug 18 '21 at 20:24
36

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

screenshot of terminal output

Ashad Nasim
  • 2,511
  • 21
  • 37
Hemanth Kumar
  • 809
  • 1
  • 7
  • 7
11

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
Davinder
  • 5,107
  • 1
  • 11
  • 8
8

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.

David Buck
  • 3,752
  • 35
  • 31
  • 35
3

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.
Anil Gupta
  • 147
  • 7
3
npm cache verify
npm install -g create-react-app
Furkan Yavuz
  • 1,858
  • 5
  • 30
  • 51
3

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

Nanda
  • 31
  • 1
1

This worked for me:

npm install -g degit

is like an upgrade

geisterfurz007
  • 5,292
  • 5
  • 33
  • 54
1

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
Rahul Kewat
  • 11
  • 1
  • 2
0

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.

Toni
  • 1,555
  • 4
  • 15
  • 23
0

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
Dharman
  • 30,962
  • 25
  • 85
  • 135
-1

Run npm ci. Its works for me.

Toni
  • 1,555
  • 4
  • 15
  • 23