Using create-react-app as a non root user, is this possible? - javascript

When I try to execute npx create-react-app client the result is always:
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code EPERM
npm ERR! syscall symlink
npm ERR! path ../#babel/parser/bin/babel-parser.js
npm ERR! dest /media/veracrypt1/Mega/Dev/JOBIFY/client/node_modules/.bin/parser
npm ERR! errno -1
npm ERR! Error: EPERM: operation not permitted, symlink '../#babel/parser/bin/babel-parser.js' -> '/media/veracrypt1/Mega/Dev/JOBIFY/client/node_modules/.bin/parser'
npm ERR! [Error: EPERM: operation not permitted, symlink '../#babel/parser/bin/babel-parser.js' -> '/media/veracrypt1/Mega/Dev/JOBIFY/client/node_modules/.bin/parser'] {
npm ERR! errno: -1,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'symlink',
npm ERR! path: '../#babel/parser/bin/babel-parser.js',
npm ERR! dest: '/media/veracrypt1/Mega/Dev/JOBIFY/client/node_modules/.bin/parser'
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/shmue/.npm/_logs/2022-08-11T13_45_19_897Z-debug-0.log
Aborting installation.
This is because I am not root.
It is essential that I can complete this action as the non root user.
After 20 minutes of googling I am yet to find my solution.
I am using Ubuntu 20.
Please assist me.
Many thanks, :-)
Samuel
PS: I have already chowned the user's .npm file to this user.
As per one of the answers, I updated the users .bashrc file:
Click to view my user's .bashrc file
Sadly the issue is not resolved!

You can do this operation in one of your system drivers

You can add this inside your .bashrc, and log off and log in
# this alowing installing node dependencies without root
PATH="$HOME/.local/bin:$PATH"
export npm_config_prefix="$HOME/.local"
Source: https://wiki.archlinux.org/title/Node.js

Related

Error in installing 'nodemon' using 'npm'

I recently started working with 'npm' and while installing 'nodemon' using command -
npm i -g nodemon
but it is showing ERR!
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/nodemon
npm ERR! dest /usr/local/lib/node_modules/.nodemon-SfftGed4
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/nodemon' -> '/usr/local/lib/node_modules/.nodemon-SfftGed4'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/nodemon' -> '/usr/local/lib/node_modules/.nodemon-SfftGed4'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/nodemon',
npm ERR! dest: '/usr/local/lib/node_modules/.nodemon-SfftGed4'
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/rishabhsingh/.npm/_logs/2023-01-28T12_41_30_475Z-debug-0.log
I tried using sudo to install nodemon, clearing cache using npm cache clear even with --force but no help, also tried what terminal was showing me could be the erroe but turned out nothing helpful.
Be careful with this stuff!!
Don't arbitrarily run sudo commands. Some answers online will tell you to run chmod or chown in your /usr directory. This is not a good solution and may potentially break your whole system!
The problem is that npm is trying to install global packages in your /usr folder, but your user doesn't have access to this folder. What you need to do is tell npm to install global packages in a folder which you do have access to.
Create a directory for global npm packages:
mkdir "${HOME}/.npm-packages"
Tell npm where to store globally installed packagesL
npm config set prefix "${HOME}/.npm-packages"
Ensure npm will find the location by adding it to your system's PATH variable. This can be done by editing .bashrc or .zshrc in your home directory and adding the following code to the bottom of the file.
NPM_PACKAGES="${HOME}/.npm-packages"
export PATH="$PATH:$NPM_PACKAGES/bin"
# Preserve MANPATH if you already defined it somewhere in your config.
# Otherwise, fall back to `manpath` so we can inherit from `/etc/manpath`.
export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"
Close and re-open your terminal.

Got an error while installing react router can anyone solve my problem?

I have this error
D:\>npm install react-router-dom
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path D:\
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'D:\'
npm ERR! [Error: EPERM: operation not permitted, mkdir 'D:\'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'D:\\'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
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.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\my-app\AppData\Roaming\npm-cache\_logs\2022-08-07T07_21_15_220Z-debug-0.log
It is a permission Issue.
You're running this command as a non-administrator user.
Open cmd as an administrator
and run this command,
It will work

npm, global install failing, getting Error: EACCES: permission denied

So I'm logged in as administrator of my MacBook and want to run a npm command in my Django project. However, It refuses due to missing permissions.
(venv) jonas#Air-von-Jonas salaryx % npm install -g sass
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/sass/sass.js
npm ERR! dest /usr/local/bin/sass
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/sass/sass.js' -> '/usr/local/bin/sass'
npm ERR! [Error: EACCES: permission denied, symlink '../lib/node_modules/sass/sass.js' -> '/usr/local/bin/sass'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/sass/sass.js',
npm ERR! dest: '/usr/local/bin/sass'
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jonas/.npm/_logs/2022-03-24T06_04_35_362Z-debug.log
(venv) jonas#Air-von-Jonas salaryx %
Also it seems that I can't change permissions of a folder, I can unlock the lock on the bottom right but then once I try to change permission for "wheel" e.g. it refuses as well.
You are having a system permission issue. An easy way to avoid it is to use the sudo command:
sudo npm install -g sass
Otherwise you can visit Resolving EACCES permissions errors when installing packages globally from npm's official doc. There is a guide, and the solution is to either reinstall npm with a node version manager or manually change its default directory.

Failed to install json-server on Ubuntu 20.04

I am trying to install json-server but failed repeatedly and it makes me hopeless. Now need help to makes the solution. Below the command which I have used on the Ubunto-20.04 Operating System.
Installed Nodejs version: v14.16.0
Installed NPM version: 6.14.10
And Although firstly, I used the latest version of nodejs which was 15x but I also faced an error to install json-server and below's command used to install json-server
npm install json-server -g
npm install -g json-server
npm i json-server
I have used all of the above command to install json-server but in every moments I faced error and that's given below,
Here is error
checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
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! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/imdadul/.npm/_logs/2021-03-18T04_32_41_181Z-debug.log
Note: The error also added in the attached file and Advanced thanks for your helps.
You could try with sudo like "sudo npm install -g json-server" or give write permission with "chmod -r 777 /usr/local/lib/node_modules". I think that sudo option is better for instant permisson.
You're running the command with the right permissions, you should chmod the node_modules and run the command again with sudo.

Problem installing nodemon globally on macOS Mojave

In the Visual Studio Code terminal I issue to following command:
npm install -g nodemon
The result in terminal is:
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
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! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/ilkin/.npm/_logs/2020-08-30T16_39_29_236Z-debug.log
How can I solve it?
Use sudo before installing, it will ask for credentials enter it and done
sudo npm i - g nodemon
This means that you do not have root privileges / are not a superuser. You have two ways to solve this.
Use sudo before the command - this will usually then ask for credentials and run the command without a problem (hopefully)
Run sudo -s to automatically run commands with sudo every time in the current terminal window (will deactivate once the terminal has been closed)
Run sudo su which will make the computer think that the current terminal window has been opened by a root user (again will deactivate once current window has been closed)

Categories