npm install -g create-react-app failed + Ubuntu 18.04

jp@jp:~$ npm install -g create-react-app
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path …/lib/node_modules/create-react-app/index.js
npm ERR! dest /home/jp/.npm-global/bin/create-react-app
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 1000:1000 “/home/jp/.npm”

npm ERR! A complete log of this run can be found in:
npm ERR! /home/jp/.npm/_logs/2019-10-24T13_13_35_073Z-debug.log

.npm folder is available on path ./home/ not in ./home/jp/

I have already install node 10 and npm .

How to fix this issue ?

NOTE: I am new user on ubuntu OS so not able to fix this issues

Have you run the suggested command?

sudo chown -R 1000:1000 /home/jp/.npm

Thanks for your response.

Yes, I tried this command but getting same issue.

It seems problem with folder permission. Actually below path is not available

/home/jp/.npm-global/lib/node_modules

When I tried to browse .npm-global folder it was available on below location

/home/.npm-global/lib/node_modules

Any idea why this is happening ?

Thanks in advance for help.

It looks like your npm is configured to use a custom prefix for the global packages. What does this show?

npm prefix -g

One of the common ways of avoiding permissions problems and avoid need to use sudo for global packages is to use a folder in your home folder for the global packages. What I guess may have happened is you were following some instructions but have accidentally made the .npm-global beside your home folder instead of inside your home folder. Do you recall setting a prefix? Or is this the way the system has been configured by someone else? (Are you on a multi-user computer?)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.