Need to run npm install with sudo, else I get Errno -5 - npm

I git clone a Node app.
Then I try to install all the dependencies with npm install.
I get the following error.
npm ERR! code EIO
npm ERR! syscall read
npm ERR! errno -5
npm ERR! EIO: i/o error, read
npm ERR! A complete log of this run can be found in:
npm ERR! /home/foobar/.npm/_logs/2020-02-22T12_14_17_084Z-debug.log
The last lines of the log file look like this:
...
...
3830 silly saveTree └── typescript#3.8.2
3831 verbose stack Error: EIO: i/o error, read
3832 verbose cwd /home/foobar/myapp
3833 verbose Linux 5.4.18-1-MANJARO
3834 verbose argv "/usr/bin/node" "/usr/bin/npm" "install"
3835 verbose node v13.7.0
3836 verbose npm v6.13.6
3837 error code EIO
3838 error syscall read
3839 error errno -5
3840 error EIO: i/o error, read
3841 verbose exit [ -5, true ]
When I prepend the command with sudo it installs.
How can I fix this error so I don't need to run npm install with sudo?

I fixed it by deleting my ~/.npm and other node related directories in $HOME.

Related

Why I am facing error while installing Nodemon?

Last login: Sun Sep 19 13:02:00 on ttys000
navarajgiri#Navarajs-MacBook-Pro ~ % npm i nodemon
added 120 packages, and audited 121 packages in 708ms
11 packages are looking for funding
run npm fund for details
found 0 vulnerabilities
navarajgiri#Navarajs-MacBook-Pro ~ % npm install -g nodemon
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/navarajgiri/.npm/_logs/2021-09-19T04_04_27_310Z-debug.log
navarajgiri#Navarajs-MacBook-Pro ~ %
You use npm with the -g (global mode) option which implies system-wide install, and this requires permission (EACCESS) to do so. Either install it in local mode (without -g) possible in a virtuaelenv or run the command as root (via sudo}) as suggested.

Npm compiler : Cannot read property 'startsWith' of undefined

I did setup https://github.com/vuejs/vue-cli Vue CLI with the webpack template and it works fine.
But when i change something in template file it throws below error.
Kindly help on the below issue,
> Starting dev server...
DONE Compiled successfully in 2703ms 6:00:35 PM
> Listening at http://localhost:8083
WAIT Compiling... 6:01:05 PM
c:\xampp\htdocs\myproject\node_modules\enhanced-resolve\lib\CachedInputFileSy
stem.js:145
if(key.startsWith(what))
^
TypeError: Cannot read property 'startsWith' of undefined
at Storage.purge (c:\xampp\htdocs\myproject\node_modules\enhanced-resolve
\lib\CachedInputFileSystem.js:145:10)
at Storage.purge (c:\xampp\htdocs\myproject\node_modules\enhanced-resolve
\lib\CachedInputFileSystem.js:150:9)
at CachedInputFileSystem.purge (c:\xampp\htdocs\myproject\node_modules\en
hanced-resolve\lib\CachedInputFileSystem.js:259:20)
at EventEmitter.watcher.once (c:\xampp\htdocs\myproject\node_modules\webp
ack\lib\node\NodeWatchFileSystem.js:42:26)
at EventEmitter.g (events.js:291:16)
at emitTwo (events.js:106:13)
at EventEmitter.emit (events.js:191:7)
at EventEmitter._onTimeout (c:\xampp\htdocs\myproject\node_modules\watchp
ack\lib\watchpack.js:142:7)
at ontimeout (timers.js:380:14)
at tryOnTimeout (timers.js:244:5)
at Timer.listOnTimeout (timers.js:214:5)
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x8
6)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v6.10.2
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! dktrgo#1.0.0 dev: `node build/dev-server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the dktrgo#1.0.0 dev script 'node build/dev-server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the dktrgo package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node build/dev-server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs dktrgo
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls dktrgo
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! c:\xampp\htdocs\myproject\npm-debug.log
Thank you
I was able to reproduce in v3.4.0, but not in v3.4.1 (which was released about 5 hours later).
To confirm you're on v3.4.0:
npm list enhanced-resolve
Please update enhanced-resolve to v3.4.1:
npm i enhanced-resolve

Error on NPM install - Phantomjs#1.9.18

Getting this every time I try to install mean.io application have tried
npm cache clean,
tried total reinstall ,
going mad at the moment . Am also running this as administrator. pleas help
C:\Users\mmcelhinney\pitch_v1>npm install
-
> phantomjs#1.9.18 install C:\Users\mmcelhinney\pitch_v1\node_modules\phantomjs
> node install.js
Download already available at C:\Users\MMCELH~1\AppData\Local\Temp\phantomjs\phantomjs-1.9.8-windows.zip
Extracting zip contents
Removing C:\Users\mmcelhinney\pitch_v1\node_modules\phantomjs\lib\phantom
Copying extracted folder C:\Users\MMCELH~1\AppData\Local\Temp\phantomjs\phantomjs-1.9.8-windows.zip-extract-1456238458670\phantomjs-1.9.8-windows -> C:\Users\mmcelhinney\pitch_v1\node_modules\phantom
s\lib\phantom
Phantom installation failed { [Error: EPERM, unlink 'C:\Users\MMCELH~1\AppData\Local\Temp\phantomjs\phantomjs-1.9.8-windows.zip-extract-1456238458670\phantomjs-1.9.8-windows\phantomjs.exe']
errno: -4048,
code: 'EPERM',
path: 'C:\\Users\\MMCELH~1\\AppData\\Local\\Temp\\phantomjs\\phantomjs-1.9.8-windows.zip-extract-1456238458670\\phantomjs-1.9.8-windows\\phantomjs.exe' } Error: EPERM, unlink 'C:\Users\MMCELH~1\App
ata\Local\Temp\phantomjs\phantomjs-1.9.8-windows.zip-extract-1456238458670\phantomjs-1.9.8-windows\phantomjs.exe'
at Error (native)
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ELIFECYCLE
npm ERR! phantomjs#1.9.18 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs#1.9.18 install script 'node install.js'.
npm ERR! This is most likely a problem with the phantomjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls phantomjs
npm ERR! There is likely additional logging output above.
npm ERR! error rolling back Error: EPERM, unlink 'C:\Users\mmcelhinney\pitch_v1\node_modules\phantomjs\lib\phantom\phantomjs.exe'
npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EPERM, unlink 'C:\Users\mmcelhinney\pitch_v1\node_modules\phantomjs\lib\phantom\phantomjs.exe']
npm ERR! error rolling back errno: -4048,
npm ERR! error rolling back code: 'EPERM',
npm ERR! error rolling back path: 'C:\\Users\\mmcelhinney\\pitch_v1\\node_modules\\phantomjs\\lib\\phantom\\phantomjs.exe' }
Excerpt from Debug log as well :
6379 info phantomjs#1.9.18 Failed to exec install script
6380 verbose unlock done using C:\Users\mmcelhinney\AppData\Roaming\npm-cache_locks\phantomjs-69c2bf63828d859c.lock for C:\Users\mmcelhinney\pitch_v1\node_modules\phantomjs
6381 verbose stack Error: phantomjs#1.9.18 install: node install.js
6381 verbose stack Exit status 1
6381 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:213:16)
6381 verbose stack at EventEmitter.emit (events.js:110:17)
6381 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:14:12)
6381 verbose stack at ChildProcess.emit (events.js:110:17)
6381 verbose stack at maybeClose (child_process.js:1008:16)
6381 verbose stack at Process.ChildProcess._handle.onexit (child_process.js:1080:5)
Try my solution here https://stackoverflow.com/a/35043377/5734480
It may be slightly different depending on your OS.

Stuck with Npm? npm install errors

I am having a strange problem with npm in my ubuntu 14.04. I have a package.json file in my project directory. when i try to run
npm install
it fails. It logs something like
is related to insufficient space on your system.
But i have checked that there is enough available space in my directory.
Here is the log
npm ERR! tar.unpack untar error /home/rafi/.npm/core-js/1.2.6/package.tgz
npm ERR! tar.unpack untar error /home/rafi/.npm/caniuse-db/1.0.30000384/package.tgz
npm ERR! Linux 3.16.0-49-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! path /home/rafi/Desktop/dsf.angular/node_modules/babel-plugin-transform-export-extensions/node_modules/babel-runtime/node_modules/core-js/modules/library/es6.object.to-string.js
npm ERR! code ENOSPC
npm ERR! errno -28
npm ERR! nospc ENOSPC, open '/home/rafi/Desktop/dsf.angular/node_modules/babel-plugin-transform-export-extensions/node_modules/babel-runtime/node_modules/core-js/modules/library/es6.object.to-string.js'
npm ERR! nospc This is most likely not a problem with npm itself
npm ERR! nospc and is related to insufficient space on your system.
npm ERR! Please include the following file with any support request:
Any idea what may be the problem here ?

node gyp rebuild fail

im trying to install a nodejs application but I keep getting the same error about "node-gyp" failing to rebuild.
I dont know a lot about nodejs, apart from I can get this to work on my local machine fine but I cant figure out why it wont run on the server.
Ubuntu 14.04
Node v0.12.5
npm v2.11.2
> ws#0.4.32 install /root/banquo-server/node_modules/node-phantom/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/root/banquo-server/node_modules/node-phantom/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/build'
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
make: Leaving directory `/root/banquo-server/node_modules/node-phantom/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/build'
> ref#1.0.2 install /root/banquo-server/node_modules/exec-sync/node_modules/ffi/node_modules/ref
> node-gyp rebuild
make: Entering directory `/root/banquo-server/node_modules/exec-sync/node_modules/ffi/node_modules/ref/build'
CXX(target) Release/obj.target/binding/src/binding.o
make: g++: Command not found
make: *** [Release/obj.target/binding/src/binding.o] Error 127
make: Leaving directory `/root/banquo-server/node_modules/exec-sync/node_modules/ffi/node_modules/ref/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Linux 3.13.0-52-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/banquo-server/node_modules/exec-sync/node_modules/ffi/node_modules/ref
gyp ERR! node -v v0.12.5
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm ERR! Linux 3.13.0-52-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.5
npm ERR! npm v2.11.2
npm ERR! code ELIFECYCLE
npm ERR! ref#1.0.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ref#1.0.2 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the ref package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls ref
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/banquo-server/npm-debug.log
Any help much appreciated.
Regards
Luke
It seems you have a conflict with an older package that is getting in the way.
Try below commands helped me to resolve the issue, might help you too... these commands might need sudo access
npm cache clean -f
npm install -g n
n stable
npm install npm -g
So above solves the problem when there is any conflict in packages version.... but by looking at logs it says make: g++: Command not found Which means you need to install developer tools
have you tried installing node-gyp via apt-get install:
apt-get install node-gyp
The command g++ is not found, so you need to install the g++ package (along with build-essential which includes other packages that are required to build/compile programs):
sudo apt-get install build-essential g++