Linux npm permission denied

Install ReactJS on Ubuntu 18.04 — npm permission denied

I am new to Linux and I am trying to get set-up with nodejs, but I have not been able to figure out why I can’t install react. I am following directions that I have seen on the web, but I am wondering why I seem to not have the privileges necessary to install react. It’s a personal environment, so I wasn’t expecting any issue. Below is what I have run and the final error that the last line gave me.

sudo apt update && sudo apt upgrade sudo apt install nodejs sudo npm install npm node -v v8.10.0 npm -v 3.5.2 sudo npm install npm@latest -g npm -v 6.10.0 npm install -g create-react-app 

Everything above runs just fine until the last command. Then I get the following error, regardless of working directory.

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: '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! /home/me/.npm/_logs/2019-07-06T19_33_32_971Z-debug.log 

Источник

Читайте также:  Linux delete all old files

Permission denied when installing npm module

I’m getting a strange permission error when I try to install an npm module. I’m starting it with sudo so I’m sure I do have access, but for some reason it keeps complaining with an error:

stack Error: EACCES: permission denied, mkdir ‘/usr/lib/node_modules/joplin/node_modules/sqlite3/build’

I’ve tried restarting my computer, and creating a directory /usr/lib/node_modules/joplin with chmod 777, but it still doesn’t work.

$ sudo npm install -g joplin /usr/bin/joplin -> /usr/lib/node_modules/joplin/main.js > sqlite3@3.1.9 install /usr/lib/node_modules/joplin/node_modules/sqlite3 > node-pre-gyp install --fallback-to-build node-pre-gyp ERR! Tried to download(undefined): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.9/node-v48-linux-x64.tar.gz node-pre-gyp ERR! Pre-built binaries not found for sqlite3@3.1.9 and node@6.11.2 (node-v48 ABI) (falling back to source compile with node-gyp) gyp ERR! configure error gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/joplin/node_modules/sqlite3/build' gyp ERR! stack at Error (native) gyp ERR! System Linux 4.4.0-43-Microsoft gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/lib/node_modules/joplin/node_modules/sqlite3/lib/binding/node-v48-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/usr/lib/node_modules/joplin/node_modules/sqlite3/lib/binding/node-v48-linux-x64" gyp ERR! cwd /usr/lib/node_modules/joplin/node_modules/sqlite3 gyp ERR! node -v v6.11.2 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/lib/node_modules/joplin/node_modules/sqlite3/lib/binding/node-v48-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/usr/lib/node_modules/joplin/node_modules/sqlite3/lib/binding/node-v48-linux-x64' (1) node-pre-gyp ERR! stack at ChildProcess. (/usr/lib/node_modules/joplin/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/compile.js:83:29) node-pre-gyp ERR! stack at emitTwo (events.js:106:13) node-pre-gyp ERR! stack at ChildProcess.emit (events.js:191:7) node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:891:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) node-pre-gyp ERR! System Linux 4.4.0-43-Microsoft node-pre-gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/joplin/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR! cwd /usr/lib/node_modules/joplin/node_modules/sqlite3 node-pre-gyp ERR! node -v v6.11.2 node-pre-gyp ERR! node-pre-gyp -v v0.6.36 node-pre-gyp ERR! not ok 

Edit I’ve also tried sudo npm i sqlite3 -g —build-from-source but getting the same error Error: EACCES: permission denied, mkdir ‘/usr/lib/node_modules/sqlite3/build’ so it seems to be something to do with sqlite3.

Читайте также:  Linux dotnet command not found

Источник

NPM install permission denied error using root user

So I’ve made a fresh installation of npm/node on my local machine using NVM using root user and everything looks fine, now my issue is when I tried to install using npm install —unsafe-perm -verbose command on my project folder error displays in my terminal.

npm verb stack Error: Command failed: /usr/bin/git clone --depth=1 -q -b 0.0.7 https://github.com/Mango/emitter.git /root/.npm/_cacache/tmp/git-clone-28a98ad9 npm verb stack fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-28a98ad9': Permission denied npm verb stack npm verb stack at ChildProcess.exithandler (child_process.js:282:12) npm verb stack at ChildProcess.emit (events.js:182:13) npm verb stack at maybeClose (internal/child_process.js:957:16) npm verb stack at Socket.stream.socket.on (internal/child_process.js:378:11) npm verb stack at Socket.emit (events.js:182:13) npm verb stack at Pipe._handle.close [as _onclose] (net.js:598:12) npm verb cwd /web/nbltv npm verb Linux 4.15.0-29-generic npm verb argv "/root/.nvm/versions/node/v10.1.0/bin/node" "/root/.nvm/versions/node/v10.1.0/bin/npm" "install" "--unsafe-per" "-verbose" npm verb node v10.1.0 npm verb npm v5.6.0 npm ERR! code 128 npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b 0.0.7 https://github.com/Mango/emitter.git /root/.npm/_cacache/tmp/git-clone-28a98ad9 npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-28a98ad9': Permission denied npm ERR! npm verb exit [ 1, true ] npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2018-08-20T01_36_33_496Z-debug.log 

Источник

Оцените статью
Adblock
detector