Home > Enterprise >  what should I do with the n upgrade node permission in fedora 32
what should I do with the n upgrade node permission in fedora 32

Time:12-05

I am using this command to upgrade the node version in fedora 32:

npm install -g n
n stable

when I using the n stable command, shows error like this:

cp: cannot remove '/usr/local/bin/corepack': Permission denied
cp: cannot remove '/usr/local/bin/npm': Permission denied
cp: cannot remove '/usr/local/bin/npx': Permission denied
cp: cannot remove '/usr/local/include/node/common.gypi': Permission denied
cp: cannot remove '/usr/local/include/node/config.gypi': Permission denied
cp: cannot remove '/usr/local/include/node/node.h': Permission denied
cp: cannot remove '/usr/local/include/node/node_api.h': Permission denied
cp: cannot remove '/usr/local/include/node/js_native_api.h': Permission denied
cp: cannot remove '/usr/local/include/node/js_native_api_types.h': Permission denied
cp: cannot remove '/usr/local/include/node/node_api_types.h': Permission denied
cp: cannot remove '/usr/local/include/node/node_buffer.h': Permission denied
cp: cannot remove '/usr/local/include/node/node_object_wrap.h': Permission denied
cp: cannot remove '/usr/local/include/node/node_version.h': Permission denied
cp: cannot remove '/usr/local/include/node/v8config.h': Permission denied
cp: cannot remove '/usr/local/include/node/v8-internal.h': Permission denied

I did not want to using root user to upgrade the node, what should I do? Just change the /usr/local folder permission to current user? does this way had any side effect? I am not sure, what is the best way to make the n stable command work?

CodePudding user response:

The installation section in the documentation of n has instructions to avoid using sudo or working as an admin.

Quoting from the current version:

To avoid requiring sudo for n and npm global installs, it is suggested you either install to your home directory using N_PREFIX, or take ownership of the system directories:

# make cache folder (if missing) and take ownership
sudo mkdir -p /usr/local/n
sudo chown -R $(whoami) /usr/local/n
# make sure the required folders exist (safe to execute even if they already exist)
sudo mkdir -p /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share
# take ownership of Node.js install destination folders
sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share
  • Related