NPM install giving error installing express - node.js

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

Related

How to update npm in WSL 2 Ubuntu

I'm trying to update my ancient npm 3.5.2 that is running in the Windows Subsystem for Linux on my Windows 10 to the latest version.
The command I'm running is as follows:
sudo npm install -g npm#latest
However, it fails and all I'm getting is the following output:
WARN engine npm#7.20.5: wanted: {"node":">=10"} (current: {"node":"8.10.0","npm":"3.5.2"})
/usr/local/lib
└── (empty)
sudo apt install wsl
npm ERR! Linux 5.10.16.3-microsoft-standard-WSL2
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "npm#latest"atest
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! path /usr/local/lib/node_modules/.staging/#npmcli/ci-detect-c7bf9552
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/#npmcli/ci-detect-c7bf9552' -> '/usr/local/lib/node_modules/npm/node_modules/#npmcli/ci-detect'
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/#npmcli/ci-detect-c7bf9552' -> '/usr/local/lib/node_modules/npm/node_modules/#npmcli/ci-detect'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /mnt/d/Summbit/Humanatomy.Web/npm-debug.log
npm ERR! code 1
I'm clueless what npm is trying to tell me. Does anyone know what is going on here?
I found this article that detailed the steps that eventually enabled me to update npm. These are the steps that I followed:
Step:
sudo npm cache clean -f
output:
npm WARN using --force I sure hope you know what you are doing.
Step:
sudo npm install -g n
output:
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
/usr/local/lib
└── n#7.3.1
Step:
sudo n stable
output:
installing : node-v14.17.4
mkdir : /usr/local/n/versions/node/14.17.4
fetch : https://nodejs.org/dist/v14.17.4/node-v14.17.4-linux-x64.tar.xz
installed : v14.17.4 (with npm 6.14.14)
Note: the node command changed location and the old location may be remembered in your current shell.
old : /usr/bin/node
new : /usr/local/bin/node
To reset the command location hash either start a new shell, or execute PATH="$PATH"
Step:
sudo n latest
output:
installing : node-v16.6.1
mkdir : /usr/local/n/versions/node/16.6.1
fetch : https://nodejs.org/dist/v16.6.1/node-v16.6.1-linux-x64.tar.xz
installed : v16.6.1 (with npm 7.20.3)
Step:
Close the shell and open a new one
Step:
npm --version
output:
7.20.3
There's a workaround:
npm install -g yarn
yarn global add npm
~/.yarn/bin/npm install -g npm
Some thing to note:
my nodejs was installed using nvm under ~/.nvm
you need to close vscode if you have it running in wsl mode, and restart bash. some file might be hold by vscode-server process.

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

Unable to upgrade npm from 1.4.28 to latest (2.2)

I'm using stable version of node on Ubuntu 14.04. (installed via PPA) When I was trying to upgrade some packages like yo, I got the error below:
npm ERR! notsup Unsupported
npm ERR! notsup Not compatible with your version of node/npm: yo#1.4.2
npm ERR! notsup Required: {"node":">=0.10.0","npm":">=2.1.0"}
npm ERR! notsup Actual: {"npm":"1.4.28","node":"0.10.35"}
npm ERR! System Linux 3.13.0-32-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "update" "-g"
npm ERR! cwd /home/ekrem
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! code ENOTSUP
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/ekrem/npm-debug.log
npm ERR! not ok code 0
When I hit (sudo) npm update -g npm, here's the result I got:
npm#2.1.3 /home/ekrem/.node/lib/node_modules/ionic/node_modules/npm
After hitting npm -v
1.4.28
I've also cleared all files under ~/.npm, cleared cache, reinstall components I needed but nothing changes. In addition;
➜ ~ which node
/usr/bin/node
➜ ~ which npm
/usr/bin/npm
➜ ~ less ~/.npmrc
prefix = ~/.node
I've checked similar issues on the net but there's nothing close to mine.
UPDATE:
I've removed nodejs; cleared files under ~/.node & ~/.npm (as #johns has suggested) installed using first method of the instructions here. Here are updated outputs:
➜ node -v
v0.10.35
➜ npm -v
1.4.28
➜ which node
/home/ekrem/local/bin/node
➜ which npm
/home/ekrem/local/bin/npm
➜ npm update -g npm
# returns nothing
➜ ~ npm config get prefix
/home/ekrem/.node
I was facing a similar issue and found this post. The way I got npm to work after several tries is to remove all the npm 'node_module' folders and delete any npm config files particularly the .npmrc file in your home directory.
Then I ran 'sudo apt-get purge nodejs'.
I went to the installer and reinstalled nodejs using the following:
'curl https://npmjs.org/install.sh | sh'
then ran:
sudo apt-get install nodejs
Finally I ran:
npm update -g npm
There were issues posted about a bug in that 'update' function, but it seemed to work for me and I got from 1.4 to 2.7.
I hope this saves someone some time.
This solution worked for me
navigate to C:\Program Files (x86)\nodejs with cmd.exe and then run the installation without -g:
npm install npm
In my case I had to do the following steps to go from npm#1.4.28 to npm#3.2.0 (currently the latest):
curl -L https://www.npmjs.org/install.sh | sudo sh
This line may trigger some errors like:
Error: EACCES, mkdir '/usr/lib/node_modules/npm'
If so, simply run:
sudo rm -rf /usr/lib/node_modules/npm (or the specified directory display in the error)
From there:
sudo npm install -g npm#3.0-latest
And now the
npm -v
successfully display a beautiful: 3.2.0
There are a lot of comments out there about "npm update -g" being broken and to not use it for now:
https://github.com/npm/npm/issues/6247
I'd trying resetting or reinstalling npm and then go from there - a fresh reinstall of npm should be relatively painless and fix things:
https://github.com/npm/npm/wiki/Troubleshooting#if-your-npm-is-broken
Similar answer to #ThinkBonobo, but all I had to do was run the update straight from npmjs.org. From a freshly provisioned instance:
$curl -sL https://deb.nodesource.com/setup | sudo bash -
$sudo apt-get install nodejs
$npm -v
1.4.28
$curl -L https://npmjs.org/install.sh | sudo sh
$npm -v
2.7.3
No other steps were requried.

npm install error ENOTDIR

I am very new to Node.js and trying to install Flatiron using npm but it gives me an error.
sudo npm install flatiron -g
And I get -
npm http GET https://registry.npmjs.org/flatiron
npm http 304 https://registry.npmjs.org/flatiron
npm ERR! Error: ENOTDIR, mkdir '/home/siddharthsaha/tmp/npm-28554/1353323290836-0.20847953506745398'
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Linux 3.2.0-24-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "flatiron" "-g"
npm ERR! cwd /home/siddharthsaha/denarit
npm ERR! node -v v0.8.14
npm ERR! npm -v 1.1.65
npm ERR! path /home/siddharthsaha/tmp/npm-28554/1353323290836-0.20847953506745398
npm ERR! code ENOTDIR
npm ERR! errno 27
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/siddharthsaha/denarit/npm-debug.log
npm ERR! not ok code 0
What is wrong here? I have no clue.
Just solved the issue. Its because there's a file called tmp in the home directory.
rm -rf ~/tmp
sudo npm cache clear
sudo npm install -g node
Also... if you are trying to install npm then the same error and solution applies - delete ~/tmp
Try
sudo mkdir -p /home/siddharthsaha/tmp
sudo npm cache clear
before starting the install script, since npm http 304 https://registry.npmjs.org/flatiron line states that this module is coming from cache. And also ENOTDIR states that there is no directory. Therefore, emptying the cache would solve your problem.
Below are the steps to install a given release from source without root
NOTE - this installs nodejs which gives you both node as well as npm,
they come together per release.
to start fresh remove prior node.js and npm installs as well as these :
sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm ~/.npm_ignore
sudo mv ~/tmp ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore
to install nodejs and npm as yourself NOT root do these commands (OSX/linux) :
export NODE_PARENT=${HOME}/bin_0_10_32
mkdir ${NODE_PARENT}
download source from : http://nodejs.org/download/
cd node-v0.xxxx
./configure --prefix=${NODE_PARENT}/nodejs
make -j8
make install # IMPORTANT this is NOT using sudo
# not wanted since installing into $USER owned $NODE_PARENT
which puts it into dir defined by above --prefix
export PATH=${NODE_PARENT}/nodejs/bin:$PATH
define environment variable NODE_PATH so node can find dir for modules otherwise
npm install xxx will put newly installed module into current dir :
export NODE_PATH=${NODE_PARENT}/nodejs/lib/node_modules
when you use syntax : npm install -g some_cool_module
the -g for global installs it into dir $NODE_PATH and not your $PWD
nodejs install gives you npm as well :
ls -la ${NODE_PARENT}/nodejs/bin
Subsequent modules you install using global flag -g will automagically put
their ~binaries~ into above bin dir ... like browserify
Now put above three export xxx=yyy
commands into your ~/.bashrc or some such so your environment is setup
I direct delete the file of npm-debug.log.
then it's ok for me.

npm packager installation errors

I ran the command -
sudo curl http://npmjs.org/install.sh | sh
But I am getting this Error. Can anyone help?
Password:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
101 7881 101 7881 0 0 5165 0 0:00:01 0:00:01 --:--:-- 7696
tar=/usr/bin/tar
version:
bsdtar 2.6.2 - libarchive 2.6.2
install npm#1.0
fetching: http://registry.npmjs.org/npm/-/npm-1.0.106.tgz
0.5.11-pre
1.0.106
cleanup prefix=/usr/local
All clean!
npm ERR! Could not create /usr/local/lib/node_modules/___npm.npm
npm ERR! error installing npm#1.0.106 Error: EACCESS, Permission denied '/usr/local/lib/node_modules'
npm ERR! Error: EACCESS, Permission denied '/usr/local/lib/node_modules'
npm ERR! Report this *entire* log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR!
npm ERR! System Darwin 10.8.0
npm ERR! command "/usr/local/bin/node" "/private/var/folders/a4/a4oBVIXZEDS3kWEMo4Gh8U+++TI/-Tmp-/npm.4405/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/a4/a4oBVIXZEDS3kWEMo4Gh8U+++TI/-Tmp-/npm.4405/package
npm ERR! node -v v0.5.11-pre
npm ERR! npm -v 1.0.106
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCESS
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/a4/a4oBVIXZEDS3kWEMo4Gh8U+++TI/-Tmp-/npm.4405/package/npm-debug.log
npm not ok
It failed
They recommend to not use Sudo on this site: http://howtonode.org/introduction-to-npm, and to instead use:
sudo chown -R $USER /usr/local
Followed by:
curl http://npmjs.org/install.sh | sh
Call the command using sudo:
sudo curl http://npmjs.org/install.sh | sudo sh
Below are the steps to install a given release from source
NOTE - this installs nodejs which gives you both node as well as npm,
they come together per release.
to start fresh remove prior node.js and npm installs as well as these :
sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm ~/.npm_ignore
sudo mv ~/tmp ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore
to install nodejs and npm as yourself NOT root do these commands (OSX/linux) :
export NODE_PARENT=${HOME}/bin_0_10_32
mkdir ${NODE_PARENT}
download source from : http://nodejs.org/download/
cd node-v0.xxxx
./configure --prefix=${NODE_PARENT}/nodejs
make -j8
make install # IMPORTANT this is NOT using sudo
# not wanted since installing into $USER owned $NODE_PARENT
which puts it into dir defined by above --prefix
export PATH=${NODE_PARENT}/nodejs/bin:$PATH
define environment variable NODE_PATH so node can find dir for modules otherwise
npm install xxx will put newly installed module into current dir :
export NODE_PATH=${NODE_PARENT}/nodejs/lib/node_modules
when you use syntax : npm install -g some_cool_module
the -g for global installs it into dir $NODE_PATH and not your $PWD
nodejs install gives you npm as well :
ls -la ${NODE_PARENT}/nodejs/bin
Subsequent modules you install using global flag -g will automagically put
their ~binaries~ into above bin dir ... like browserify
Now put above three export xxx=yyy
commands into your ~/.bashrc or some such so your environment is setup

Resources