I can't install React! How can I fix this? - reactjs

I'm trying to install React, but I obtain the error below, how can I fix them?
I'm trying to install with:
npm install -g create-react-app
npm ERR! code EACCES
npm ERR! syscall open
npm ERR! path /home/pedro/.npm/_cacache/tmp/09106e29
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/pedro/.npm"
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pedro/.npm/_logs/2019-10-25T14_14_48_169Z-debug.log

According to the information provided by the error logs you just need to give the user under which npm package manager is running the proper permission to the folder /home/pedro/.npm.
The command provided as information should to it: sudo chown -R 1000:1000 "/home/pedro/.npm"
You can read a bit more about this folder in what is ~/.npm dir for?

Related

Issues with installing surge

I was trying to install Surge in order to publish my project but my terminal gave me the following error message:
npm ERR! code EACCES`
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/surge
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/surge'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/surge'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/surge'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
I am not sure what I need to do. I am the administrator of the computer and the command I ran was npm install -g surge. I am on Mac OS Monterey version 12.4
Any help would be much appreciated.
Thanks
works for me like this:
npm i --package-lock-only
npm cache clean --force
npm audit fix --force
I just ran the command it says to.
npm i --package-lock-only
npm audit fix --force
Anytime it give you permission issues then use sudo at start!
Then it showed me 0 vulnerabilities. Anyway, ran again audit fix and again 0 vulnerabilities.

Trying to install Expo-cli, But experiencing Error Codes like NPM Install Errors Like EACCES, AND ENOEMPTY

I am new to react native and I am having an issue installing expo-cli, and I get two different errors depending on how I try to install expo-cli. If I do npm install --global expo-cli, it gives the EACCES error.
This is what the problem looks like:
npm install --global expo-cli
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /Users/mac1/.npm-global/lib/node\_modules/expo-cli
npm ERR! dest /Users/mac1/.npm-global/lib/node\_modules/.expo-cli-sUcgOQ3i
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 501:20 "/Users/mac1/.npm"npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mac1/.npm/\_logs/2021-12-28T04\_20\_03\_084Z-debug.log
When I input sudo npm install expo-cli -g --unsafe-perm, it gives an ENOEMPTYerror like this
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /Users/mac1/.npm-global/lib/node_modules/expo-cli
npm ERR! dest /Users/mac1/.npm-global/lib/node_modules/.expo-cli-sUcgOQ3i
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/Users/mac1/.npm-global/lib/node_modules/expo-cli' -> '/Users/mac1/.npm-global/lib/node_modules/.expo-cli-sUcgOQ3i'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mac1/.npm/_logs/2021-12-29T00_39_39_814Z-debug.log
It is important to add that I have tried to other methods that might solve this problem like, yarn add global expo-cli , sudo chown, npm cache clean --force, . But nothing has worked, I'm not sure if the methods don't work, or if I'm doing the procedure wrong.
Thank You for Your Time!
Option 1: I would recommend you install node js by using the nvm(node version manager). That way you can have different versions of node js installed on your system and you can easily switch versions. Then try using an earlier node version like 14 to install expo-cli
Option 2: Debug - Go through the log file, you are going to see where the error is coming from1

Error in installing :- npm install -g create-react-app

I was going through "Modern React with Redux Course" on Udemy, there instructor asked to install NodeJs first and then to install " npm install -g create-react-app", When i tried to run this command , i got an error :-
npm install -g create-react-app
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/nitintushir/.npm/_logs/2019-09-20T15_22_12_437Z-debug.log
then i go through a some questions on stackoverflow, where someone suggests to run this command :-
npm cache clean --force
to which i got :
npm WARN using --force I sure hope you know what you are doing.
then i run the
npm install -g create-react-app
command again , but still got the same error , any solution/suggestion ?
It look like an access right error, you should try running your install as root like:
sudo npm install -g create-react-app
You should use nvm to manage your node and npm versions.
https://github.com/nvm-sh/nvm
This would allow you to globally install node modules without any sudo permission
And also you can change your node version anytime you want with nvm CLI

error when npm install

I'm a beginner and I'm trying to learn Angular so I'm trying to install a new project with angular-seed. But when I do npm install I get an error that I dont know where is coming from. I have node installed. The version is 5.5.0. Ad this is the error I get in console.
npm verb install Error: Unsupported
npm verb install at checkPlatform (/usr/lib/node_modules/npm/node_modules/npm-install-checks/index.js:46:14)
npm verb install at Array. (/usr/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
npm verb install at LOOP (/usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
npm verb install at /usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:18:7
npm verb install at checkEngine (/usr/lib/node_modules/npm/node_modules/npm-install-checks/index.js:25:10)
npm verb install at Array. (/usr/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
npm verb install at LOOP (/usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
npm verb install at chain (/usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:5)
npm verb install at module.exports.isInstallable (/usr/lib/node_modules/npm/lib/install/validate-args.js:26:3)
npm verb install at resolveWithNewModule (/usr/lib/node_modules/npm/lib/install/deps.js:452:12)
npm verb lock using /home/david/.npm/_locks/staging-7c9a6a9e85daffeb.lock for /home/david/DiabetesApp/angular-seed/node_modules/.staging
npm verb unlock done using /home/david/.npm/_locks/staging-7c9a6a9e85daffeb.lock for /home/david/DiabetesApp/angular-seed/node_modules/.staging
npm verb stack Error: EACCES: permission denied, mkdir '/home/david/DiabetesApp/angular-seed/node_modules/.staging'
npm verb stack at Error (native)
npm verb cwd /home/david/DiabetesApp/angular-seed
npm ERR! Linux 3.13.0-76-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--verbose"
npm ERR! node v5.5.0
npm ERR! npm v3.3.12
npm ERR! path /home/david/DiabetesApp/angular-seed/node_modules/.staging
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/home/david/DiabetesApp/angular-seed/node_modules/.staging'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, mkdir '/home/david/DiabetesApp/angular-seed/node_modules/.staging']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/home/david/DiabetesApp/angular-seed/node_modules/.staging' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm verb exit [ -13, true ]
npm ERR! Please include the following file with any support request:
npm ERR! /home/david/DiabetesApp/angular-seed/npm-debug.log
ISSUE: You (the user) don't have the right set of permissions for the directory.
The instant way out is to run the npm install using sudo, but this may give you the same error, or improper installation.
Solution/Suggestion: Change npm's Default Directory (from official docs)
Back-up your computer before moving forward.
(optional) In case you have a erroneous installation, first uninstall it:
npm uninstall <package-name> # use sudo if you used it while installation
npm cache verify # or, npm cache clean for npm version below 5.x.x
Make a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
Open or create a ~/.profile or ~/.bash_profile file and add this line:
export PATH=~/.npm-global/bin:$PATH
Back on the command line, update your system variables, or restart the terminal:
source ~/.profile
(optional) Test: Download a package globally without using sudo.
npm install -g jshint
"Please try running this command again as root/Administrator."
Try sudo npm install.
This is a permission problem. You must fix permissions on this directory, and run npm install without sudo.
cd your_working_directory
sudo chown -R $( whoami ):$( whoami ) .
sudo chmod -R 755 .
npm install
To avoid EACCESS errors do reinstall node and npm with Node Version Manger (as per written in npm documentation).
For furtner details visit this post:
https://stackoverflow.com/a/49126536/5506730

Installing Yeoman errors

I am new to Ubuntu and to Angular. I am attempting to set up a Yeoman framework. However each time I run the "yo" command. the following errors occur:
Error: EACCES, mkdir '/home/diarmuid/tmp/npm-2997-20XPEB7W'
npm ERR! { [Error: EACCES, mkdir '/home/diarmuid/tmp/npm-2997-20XPEB7W']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/diarmuid/tmp/npm-2997-20XPEB7W',
npm ERR! parent: 'davidmoshertutorial' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.8.0-35-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/diarmuid/AngularTutorial/DavidMosherTutorial
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! path /home/diarmuid/tmp/npm-2997-20XPEB7W
npm ERR! code EACCES
npm ERR! errno 3
Does anyone understand how to solve this? I tried to run "sudo yo" however I got response to :
change to change where npm stores global packages by
putting ~/npm/bin in your PATH and running:
npm config set prefix ~/npm
I ran to gedit ~/.profile and edited the file to this:
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH:/~/npm/bin"
fi
I am obviously a bit lost. If anyone has any suggestions it would be much appreciated.
Run this command:
sudo chown -R `whoami` ~/tmp
the tmp folder within the home directory should be owned by the user, not by the admin.

Resources