How to solve npm ERR! code ERR_INVALID_OPT_VALUE - node.js

I went to install nodejs and npm on Debian9 like this with the root account because npm is not included in the legacy debian package :
curl -sL https://deb.nodesource.com/setup_8.x | bash -
.../...
## Run `apt-get install nodejs` (as root) to install Node.js v8.x and npm
:~#
:~# apt-get install -y nodejs
Now I would like to install some module with npm or to do the update of npm and I've got this error message
:~# npm cache clean -f
npm WARN using --force I sure hope you know what you are doing.
:~# npm install -g npm
npm ERR! code ERR_INVALID_OPT_VALUE
npm ERR! The value "4294967295" is invalid for option "family"
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-03-29T11_17_37_357Z-debug.log
Here the link to the debug log file : Justpasteit
Thanks for any help

Related

Failed to install angular cli using command line

I was trying to install angular cli using the command.
sudo npm install -g #angular/cli#latest
But it throws the following error:
npm ERR! path /usr/bin/ng<br>
npm ERR! code EEXIST<br>
npm ERR! Refusing to delete /usr/bin/ng: ../lib/node_modules/angular-cli/bin/ng symlink target is not controlled by npm /usr/lib/node_modules/#angular/cli<br>
npm ERR! File exists: /usr/bin/ng<br>
npm ERR! Move it away, and try again.<br>
npm ERR! A complete log of this run can be found in:
npm ERR! /home/sachin/.npm/_logs/2018-11-06T13_58_33_153Z-debug.log
I have tried the following command
sudo npm cache clear --force
sudo rm -rf /usr/local/bin/ng
But got the same above error every time.
Try :
sudo npm uninstall -g #angular/cli
sudo npm cache clean
sudo rm -rf /usr/bin/ng => Option to ensure
sudo npm i -g #angular/cli#latest

How to fix this Error -npm

I tried to install npm and I got the following error.
I already removed npm and reinstall it again, but I again got the following error:
npm ERR! Linux 4.15.0-30-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! vx-leave-system#0.0.1 start: `node ./tools/server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vx-leave-system#0.0.1 start script 'node ./tools/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 vx-leave-system package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./tools/server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs vx-leave-system
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls vx-leave-system
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/seelan/Documents/vx-leave-system/npm-debug.log
How can I fix this?
On ubuntu 18.04 following steps saved me
To remove the distro-stable version, type the following:
sudo apt remove nodejs
This command will remove the package and retain the configuration files.
sudo apt purge nodejs
As a final step, you can remove any unused packages that were automatically installed with the removed package:
sudo apt autoremove
Refresh your local package index by typing:
sudo apt update
Enable the NodeSource repository by running the following command
(optinal) If you need to install another version, for example 14.x, just change setup_12.x with setup_14.x
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
Once the NodeSource repository is enabled, install Node.js and npm by typing:
sudo apt install nodejs
Verify that the Node.js and npm were successfully installed by printing their versions:
node --version (v12.18.4)
npm --version (6.14.6)
It seems to me that you're running a newer version of Node, but an outdated version of NPM.
You can do either of the following:
Try the latest stable version of NPM:
You can upgrade to the latest version of npm using: npm install -g npm#latest
Uninstall Node form your machine completely, go to their website and install the latest stable Node version. NPM comes with it.
I faced this issue too today and the problem was caused by an upgrade in my node and npm version. Guess my project dependencies were still running on older versions of node and npm
I fixed it by deleting the node_modules folder and run
npm install
I hope this helps
This looks like a permissions issue in your home directory. To reclaim ownership of the .npm directory execute:
sudo chown -R $(whoami) ~/.npm
Check the updates of dependencies
npm outdate
Run the next command to update dependencies
npm update
Remove the path folder directory C:\Users\ACER\AppData\Local**\npm-cache_logs\2021-12-29T13_41_22_984Z-debug-0.log**
and then run this command in your CLI npm install -g npm#latest
this works with you

Problems running npm install on Elastic Beanstalck

Situation
I have a Laravel (5.4) application that uses npm, bower and gulp for frontend.
I have configured all with success on deploy but the npm install or npm install --production (that in my case is the same) command give me errors and makes the deploy to fail.
Problem
Here is the "Causes" as response from AWS when i run eb deploy command.
Application update failed at 2017-06-07T17:08:38Z with exit status 1 and error: container_command 01-npm-install in .ebextensions/05-frontend-install.config failed.
npm WARN lifecycle npm is using /usr/bin/node but there is no node binary in the current PATH. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
npm WARN deprecated minimatch#2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch#1.0.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated node-uuid#1.4.8: Use uuid module instead
npm WARN deprecated minimatch#0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs#1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs#^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN prefer global node-gyp#3.6.2 should be installed with -g
npm WARN prefer global marked#0.3.6 should be installed with -g
> node-sass#3.13.1 install /var/app/ondeck/node_modules/node-sass
> node scripts/install.js
npm ERR! file sh
npm ERR! path sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn sh
npm ERR! node-sass#3.13.1 install: `node scripts/install.js`
npm ERR! spawn sh ENOENT
npm ERR!
npm ERR! Failed at the node-sass#3.13.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-06-07T17_08_38_740Z-debug.log.
Incorrect application version "app-5d9c-170607_190633" (deployment 40). Expected version "app-0466-170606_110037" (deployment 31).
The .ebextensions/05-frontend-install.config file has this content
container_commands:
00-npm-upgrade:
command: "npm install -g npm#latest"
01-npm-install:
command: "npm install --production"
02-gulp-install:
command: "sudo npm install gulp"
03-bower-install:
command: "sudo npm install bower"
04-bower-deploy:
command: "sudo bower install --allow-root"
05-gulp-deploy:
command: "sudo npm run prod"
Achived with an EB HOOK!
I solved my problem by using a custom elastic beanstalk post-deploy platform hook (sounds great eh?)
my 04-nodenpm.config file has this content:
container_commands:
00-entersudoi:
command: "sudo -i"
01-removeoldnode:
command: " yum remove -y nodejs npm"
02-get-noderpm:
command: " curl --silent --location https://rpm.nodesource.com/setup_7.x | bash -"
03-ensurecggmake:
command: " yum install -y gcc-c++ make"
04-installnodenpm:
command: " yum install -y nodejs"
05-exitsudoi:
command: "exit"
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99npminstall.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
cd /var/app/current/
sudo npm install -g gulp bower laravel-elixir
sudo bower install --allow-root
sudo gulp --production
The part that solved the problem is under files: where i am manually adding an /opt/elasticbeanstalk/hooks/appdeploy/post/99npminstall.sh file with content: that as a post deploy action makes the npm install ... and all the stuff i wanted.
TL;DR:
npm seems not be totally available on container_commands. Use a post deploy hook to fire those npm installation commands.
Refs & Usefull links:
http://www.eq8.eu/blogs/29-aws-elasticbeanstalk-deployment-hooks
https://forums.aws.amazon.com/thread.jspa?threadID=137136

NPM install giving error installing express

When I give command npm install express it throws following error. On ubuntu machine
gaurav#gaurav-Mini-Monster:~/TestScripts$ sudo npm install -g express
npm ERR! error installing express#3.3.3 Error: Unsupported
npm ERR! error installing express#3.3.3 at checkEngine (/usr/local/lib/node_modules/npm/lib/install.js:493:14)
npm ERR! error installing express#3.3.3 at Array.0 (/usr/local/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
npm ERR! error installing express#3.3.3 at LOOP (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:13)
npm ERR! error installing express#3.3.3 at chain (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:4)
npm ERR! error installing express#3.3.3 at installOne_ (/usr/local/lib/node_modules/npm/lib/install.js:470:3)
npm ERR! error installing express#3.3.3 at installOne (/usr/local/lib/node_modules/npm/lib/install.js:411:3)
npm ERR! error installing express#3.3.3 at /usr/local/lib/node_modules/npm/lib/install.js:347:9
npm ERR! error installing express#3.3.3 at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:54:35
npm ERR! error installing express#3.3.3 at Array.forEach (native)
npm ERR! error installing express#3.3.3 at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:54:11
npm ERR! error rolling back express#3.3.3 Error: UNKNOWN, Unknown error '/usr/local/lib/node_modules/express'
npm ERR! Unsupported
npm ERR! Not compatible with your version of node/npm: connect#2.8.3
npm ERR! Required: {"node":">= 0.8.0"}
npm ERR! Actual: {"npm":"1.0.106","node":"0.5.11-pre"}
npm ERR!
npm ERR! System Linux 3.2.0-48-generic-pae
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "express"
npm ERR! cwd /home/gaurav/TestScripts
npm ERR! node -v v0.5.11-pre
npm ERR! npm -v 1.0.106
npm ERR! code ENOTSUP
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/gaurav/TestScripts/npm-debug.log
npm not ok
I also tried
sudo npm install express
npm install -g express
sudo npm install -g express
Nothing works.
Node is so easy to install manually. I like doing it this way too because it's really easy to switch versions.
This is also great because you don't need to add some external package repository to apt, and you don't have to wait for those repositories to update when node releases a new version. You can get updates as soon as they're released.
# make a `~/.nodes/ folder
mkdir -p ~/.nodes && cd ~/.nodes
# download the binaries from nodejs.org
# in this case, here's the linux version
curl -O http://nodejs.org/dist/v0.10.12/node-v0.10.12-linux-x64.tar.gz
# extract
tar -xzf node-v0.10.12-linux-x64.tar.gz
# rename folder to 0.10.12
mv node-v0.10.12-linux-x64 0.10.12
# create a `current` symlink
ln -s 0.10.12 current
# prepend ~/.nodes/bin to your path
# you'll want to save this in ~/.bashrc or ~/.zshrc or something
export PATH="~/.nodes/current/bin:$PATH"
# cleanup
rm ~/.nodes/node-v0.10.12-linux-x64.tar.gz
The best part about this is you can repeat the pattern for any other version of node, change the current symlink at any time to switch which version you're running, and you're good to go
% node --version
v0.10.12
% npm --version
1.2.32
# switch versions to (e.g.) 0.10.5
% cd ~/.nodes && rm current && ln -s 0.10.5 current
% node --version
v0.10.5
% npm --version
1.2.18
Additional pointers when writing executable scripts
Make an executable file
% touch ~/somefile && chmod +x ~/someifle && nano ~/somefile
File contents
#!/usr/bin/env node
console.log(process.version);
Run it
% ./somefile
v0.10.12
You are running a much-too-old version of node and npm. You have node v0.5 which is very out of date. Upgrade to node v0.10 and things will work.
Modern node.js versions for Ubuntu are available via this PPA from Chris Lea
To install:
sudo apt-get install python-software-properties
sudo add-apt-repository --yes ppa:chris-lea/node.js
sudo apt-get install nodejs
UPDATE
It looks like your old version of node is installed at /usr/local/bin/node. The new version from the Chris Lea PPA will be at /usr/bin/node. So to verify all is well, do:
/usr/bin/npm --version #Should be approx 1.2
/usr/bin/node --version #should be approx v0.10
/usr/bin/npm install -g express
You should uninstall the local node, or fix your PATH:
export PATH=/usr/bin:$PATH

install socket.io on ubuntu

I'm working on a real time application and I'm using third party to do it.
But now I have to use node.js with socket.io instead of third party .
I installed the node.js (v0.4.12) correctly and I check it using command node -v .
but when I was installed the socket.io using npm install socket.io command I got this error .
npm ERR! install failed Error: Required package: options(latest) not found. (Found: ["0.0.3"])
npm ERR! install failed (required by: ws#0.4.23)
npm ERR! install failed at /usr/share/npm/lib/build.js:192:19
npm ERR! install failed at cb (/usr/share/npm/lib/utils/graceful-fs.js:32:9)
npm ERR! Error: Required package: options(latest) not found. (Found: ["0.0.3"])
npm ERR! (required by: ws#0.4.23)
npm ERR! at /usr/share/npm/lib/build.js:192:19
npm ERR! at cb (/usr/share/npm/lib/utils/graceful-fs.js:32:9)
npm ERR! Report this *entire* log at <http://github.com/isaacs/npm/issues>
npm ERR! or email it to <npm-#googlegroups.com>
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm not ok
How I can solve it?
I ran those commands and it worked:
sudo npm install -g n
sudo n 0.8.15
sudo npm install socket.io
You're trying to install it without a package.json file, and in your solution you installed it globally, which is usually not what you want for socket.io.
Instead, you should include a package.json file in your working directory and either run:
> npm install socket.io --save
which will automatically append it to package.json, or your you can physically include it in the dependencies and then just run:
> npm install
It worked:
1) sudo npm install -g n
2) sudo n 0.8.15
3) sudo npm install socket.io
In some cases if you are behind a proxy and try to run:
sudo npm install socket.io
you may end up in getting error -
npm ERR! Error: shasum check failed for /tmp/npm-1393245157089/1393245157089-0.6057841922156513/tmp.tgz
npm ERR! Expected: 3bab0444e49b55fbbc157424dbd41aa375a51a76
npm ERR! Actual: dae95023b71f7d06533f7c35a7d0c3b0cf729f42
then run the following
sudo npm --proxy=http://"your_proxy":"your_port" install socket.io

Resources