Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:Windowssystem32>npm install caress-server
npm http GET https://registry.npmjs.org/caress-server
npm http 304 https://registry.npmjs.org/caress-server
npm http GET https://registry.npmjs.org/jspack/0.0.1
npm http GET https://registry.npmjs.org/buffertools
npm http 304 https://registry.npmjs.org/jspack/0.0.1
npm http 304 https://registry.npmjs.org/buffertools
> buffertools@2.0.1 install C:Windowssystem32node_modulescaress-servernode_
modulesbuffertools
> node-gyp rebuild
C:Windowssystem32node_modulescaress-servernode_modulesbuffertools>node "G:
nodejsnode_modulesnpmbinnode-gyp-bin\....node_modulesnode-gypbinnode-
gyp.js" rebuild
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack at failNoPython (G:nodejsnode_modulesnpmnode_modulesnode
-gyplibconfigure.js:101:14)
gyp ERR! stack at G:nodejsnode_modulesnpmnode_modulesnode-gyplibconfi
gure.js:64:11
gyp ERR! stack at Object.oncomplete (fs.js:107:15)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "G:\nodejs\node_modules\npm\node_modules\node-gyp\
bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:Windowssystem32node_modulescaress-servernode_modulesbuffert
ools
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm ERR! buffertools@2.0.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the buffertools@2.0.1 install script.
npm ERR! This is most likely a problem with the buffertools 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 buffertools
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "G:\nodejs\\node.exe" "G:\nodejs\node_modules\npm\bin\n
pm-cli.js" "install" "caress-server"
npm ERR! cwd C:Windowssystem32
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:Windowssystem32npm-debug.log
npm ERR! not ok code 0
C:Windowssystem32>
I am installing a certain NodeJS script — Caress. But i am not unable to. I am using Windows 8.1, can anyone tell me what is the problem i am facing, and why is this installation not working. There seems to be a problem with the buffertools dependency, thats far as i can think. Dont know how maybe fix this?
If i download the build from github and place it in node-modules, nothing seems to work. when i try to start, using npm start, or during implementation either.
G:nodejsnode_modulescaress-server>npm install
G:nodejsnode_modulescaress-server>npm start
> caress-server@0.1.1 start G:nodejsnode_modulescaress-server
> node examples/server.js
info - socket.io started
module.js:340
throw err;
^
Error: Cannot find module './build/Release/buffertools.node'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (G:nodejsnode_modulescaress-servernode_modulesbuf
fertoolsbuffertools.js:16:19)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
npm ERR! caress-server@0.1.1 start: `node examples/server.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the caress-server@0.1.1 start script.
npm ERR! This is most likely a problem with the caress-server package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node examples/server.js
npm ERR! You can get their info via:
npm ERR! npm owner ls caress-server
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "G:\nodejs\\node.exe" "G:\nodejs\node_modules\npm\bin\n
pm-cli.js" "start"
npm ERR! cwd G:nodejsnode_modulescaress-server
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! G:nodejsnode_modulescaress-servernpm-debug.log
npm ERR! not ok code 0
G:nodejsnode_modulescaress-server>
asked Jan 26, 2014 at 16:00
2
NOTE: This is an old answer that applied to earlier versions of NodeJS. My sincere gratitude to these open source projects that responded to this issue and resolved this former pain.
Make sure you have all the required software to run node-gyp
:
- https://github.com/TooTallNate/node-gyp
You can configure version of Visual Studio used by node-gyp
via an environment variable so you can avoid having to set the --msvs_version=2012
property every time you do an npm install.
Examples:
- set
GYP_MSVS_VERSION=2012
for Visual Studio 2012 - set
GYP_MSVS_VERSION=2013e
(the ‘e’ stands for FREE ‘express edition’)
For the full list see
- https://github.com/joyent/node/blob/v0.10.29/tools/gyp/pylib/gyp/MSVSVersion.py#L209-294
This is still painful for Windows users of NodeJS as it assumes you have a copy of Visual Studio installed and many end users will never have this. So I’m lobbying Joyent to the encourage them to include web sockets as part of CORE node and also to possible ship a GNU gcc compiler as part of NodeJS install so we can permanently fix this problem.
Feel free to add your vote at:
- https://github.com/joyent/node/issues/8005#issuecomment-50545326
answered Aug 1, 2014 at 1:49
Tony O’HaganTony O’Hagan
21.5k3 gold badges65 silver badges78 bronze badges
1
I encountered the issue with the error:
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
Here is what I was doing and what finally worked.
Disclaimer: I am just getting my hands into Node, Angular after many years in the Java, Linux world among others…
Environment Description: Windows 8.1 64-bit; Cygwin; cygwin bash shell
Command used that led to error: npm install -g karma
Error:
gyp ERR! configure error
gyp ERR! stack Error: Can’t find Python executable «python», you can set the PYT
HON env variable.
Discovery: ‘which python’ on bash shell clearly shows ‘/usr/bin/python’. Now that is annoying!
Solution: This is only applicable to those using the environment similar to what I have, i.e. using cygwin and bash shell. Hope it helps in other environments as well but keep in mind that your kettle of tea may look a little different than mine.
- Firstly, need to set the $PYTHON shell env variable in .bashrc using the explicit windows path to the python executable and not the unix like root path (/usr/bin) used by cygwin.
- Secondly, and this one took a lot of trial/error and here’s the gotcha! Cygwin installs python under /usr/bin (which is really a mirror of /bin on windows) with the version, i.e. (in my system) /usr/bin/python2.7.exe and then adds a link /usr/bin/python —> python2.7.exe. The problem is that gyp cannot follow this link and keeps giving the annoying error that it cannot find python even though you can find it just fine from the shell command line.
- With the above background now add the following line to your .bashrc
export PYTHON=»C:/cygwin64/bin/python2.7.exe (or whatever is the version on your system)»
- Now source your .bashrc from your home directory (on cygwin)—> ‘source .bashrc’
You should be fine now and gyp will find the python executable.
I hope this helps someone stumbling on the same or similar issue.
Preview
35.2k10 gold badges91 silver badges112 bronze badges
answered Aug 4, 2015 at 22:23
AndyAndy
1191 silver badge5 bronze badges
1
should be able get all node-gyp dependencies with chocolatey for Windows
choco install python2
choco install visualstudioexpress2013windowsdesktop
answered Mar 15, 2016 at 20:54
tarikakyoltarikakyol
5137 silver badges13 bronze badges
Setup JavaScript Environment
1. Install Node.js
Download installer at NodeJs website. You can download the latest V6
2. Update Npm
Npm is installed together with Node.js. So don’t worry.
3. Install Anaconda
Anaconda is the leading open data science platform powered by Python. The open source version of Anaconda is a high performance distribution of Python. It can help you to manage your python dependency. You can use it to create different python environment in the futher if you want to touch with it.
Node-gyp only support >= Python 2.7 and < Python 3.0
So just install the 2.7 version
4. Install Node-gyp
You can install with npm
:
$ npm install -g node-gyp
You will also need to install:
-
On Windows:
-
Option 1: Install all the required tools and configurations using Microsoft’s windows-build-tools using
npm install --global --production windows-build-tools
from an elevated PowerShell or CMD.exe (run as Administrator). -
Option 2: Install tools and configuration manually:
-
Visual C++ Build Environment:
- Option 1: Install Visual C++ Build Tools using the Default Install option.
- Option 2: Install Visual Studio 2015 (or modify an existing installation) and select Common Tools for Visual C++ during setup. This also works with the free Community and Express for Desktop editions.
💡 [Windows Vista / 7 only] requires .NET Framework 4.5.1
-
Launch cmd,
npm config set msvs_version 2015
If the above steps didn’t work for you, please visit Microsoft’s Node.js Guidelines for Windows for additional tips.
-
If you have multiple Python versions installed, you can identify which Python version node-gyp
uses by setting the ‘—python’ variable:
$ node-gyp --python C:/Anaconda2/python.exe
If node-gyp
is called by way of npm
and you have multiple versions of Python installed, then you can set npm
‘s ‘python’ config key to the appropriate value:
$ npm config set python C:/Anaconda2/python.exe
Future update for Node.js and npm
Download installer from their official website and direct install it. The installer will automatic help you to remove old files.
npm update npm
Future update for Python
conda update --all
answered Sep 22, 2016 at 9:10
Fixed with downgrading Node from v12.8.1 to v11.15.0 and everything installed successfully
answered Aug 21, 2019 at 16:35
MakMak
19.8k5 gold badges25 silver badges32 bronze badges
gyp ERR! configure error gyp ERR! stack Error: Can’t find Python
executable «python», you can set the PYT HON env variable.
This means the Python env. variable should point to the executable python file, in my case:
SET PYTHON=C:work_envPython27python.exe
answered Aug 16, 2016 at 15:07
For Cygwin users:
The python issue with using npm
on an out-of-the-box Cygwin installation, is that node-gyp
is giving a misleading error due to incomplete checking in the ../npm/node_modules/node-gyp/lib/configure.js
code.
It’s due to how Cygwin treats symbolic links. It doesn’t do that properly in an out-of-the box installation. So the error messages from the above code become misleading, as it complains about the PYTHON
path and not the existence of python.exe
(or link of) file itself.
There are (at least) 2 ways to resolve this.
- Installing the Cygwin package
cygutils-extra
and usewinln
. - Use native Windows CMD in Admin mode.
For (1) you can create a proper symlink from within Cygwin shell by doing these steps:
# To make the Cygwin environment treat Windows links properly:
# Alternatively add this to your `.bashrc` for permanent use.
export CYGWIN=winsymlinks:nativestrict
# Install Cygwin package containing "winln"
apt-cyg install cygutils-extra
# Make a proper Windows sym-link:
cd /cygdrive/c/cygwin64/bin/
winln.exe -s python2.7.exe python.exe
# Add PYTHON as a native Windows system wide variable (HKLM)
setx /M PYTHON "C:cygwin64binpython"
(Also assuming you are running the Cygwin shell as Admin.)
Using apt-cyg
is recommended and can be found in various forms on github.
For (2) the resolution for out-of-the-box Cygwin users is this:
# Open a native Windows CMD in Administrator mode and:
cd C:cygwin64bin
mklink python.exe python2.7.exe
The result should look like this:
C:cygwin64bin>ls -al python*
lrwxrwxrwx 1 xxx xxx 13 Jun 2 2015 python -> python2.7.exe
lrwxrwxrwx 1 Administrators xxx 13 Aug 24 17:28 python.exe -> python2.7.exe
lrwxrwxrwx 1 xxx xxx 13 Jun 2 2015 python2 -> python2.7.exe
-rwxr-xr-x 1 xxx xxx 9235 Jun 2 2015 python2.7.exe
answered Aug 24, 2016 at 16:05
emigenixemigenix
1011 silver badge4 bronze badges
For windows
Check python path in system variable.
npm plugins need node-gyp to be installed.
open command prompt with admin rights, and run following command.
npm install —global —production windows-build-tools
npm install —global node-gyp
answered Nov 17, 2017 at 9:07
0
I was working on an old Vue 2.x project, at least 2 years old and deps were never updated. Reverting to Node v10.16.3 worked for me. Versions 14 and 12 did not work.
answered Jul 13, 2021 at 19:10
for me the solution was:
rm -rf ~/.node_gyp and
sudo npm install -g node-gyp@3.4.0
cd /usr/local/lib sudo ln -s ../../lib/libSystem.B.dylib libgcc_s.10.5.dylib
brew install gcc
npm install
answered Jan 4, 2017 at 8:02
OrrOrr
4,7003 gold badges27 silver badges31 bronze badges
The question is already answered but these were not working in my case which is alpine Linux based OS so maybe this helps someone else.
I was also getting same error
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
So fix by single line just add this if you are working in Dockerfile or install it in OS
apk add --no-cache python nodejs
in ubuntu
sudo apt-get install python3.6
Note: Node version:8
answered Jan 3, 2018 at 8:54
AdiiiAdiii
53.4k7 gold badges143 silver badges148 bronze badges
install node-gyp and c++ compiler (gcc-c++).
answered Mar 27, 2018 at 0:24
2
npm install —global —production windows-build-tools
answered Feb 25, 2021 at 19:13
Photo from Unsplash
The npm install
command is used for installing JavaScript packages on your local computer.
When developing web projects, you may see issues that cause the npm install
command to fail.
You need to see the error message generated in the terminal for clues to resolve the error.
Some of the most common issues for npm install
not working are as follows:
- npm command not found
- No
package.json
file describing thedependencies
- Integrity check failed error
- For Windows: Python not found
Let’s see how you can resolve these errors next.
The npm command not found error
To run the npm install
command, you need to have npm installed on your computer
$ npm install
sh: command not found: npm
The error above happens when npm can’t be found under the PATH environment variable.
First, you need to make sure that npm is installed on your computer.
npm is bundled with Node.js server, which you can download from the nodejs.org website.
Once you downloaded and installed Node.js, open the terminal and run the npm -v
command.
You should see the version of npm installed on your computer as follows:
Once you see the npm version, you should be able to run the npm install
command again.
For more details, visit the fixing npm command not found error article I’ve written previously.
ENOENT: No package.json file
The npm install
command looks for a package.json
file in order to find the packages it needs to install.
You need to make sure you have a package.json
file right in the current directory where you run the command.
You can run the ls -1
command as follows:
$ ls -1
index.js
package-lock.json
package.json
Once you see there’s a package.json
file in the output as shown above, then you can run the npm install
command.
For this reason, you should always run the npm install
command from the root directory of your project.
By the way, npm install
will install packages already listed under the dependencies
object of your package.json
file.
Suppose you have a package.json
file as shown below:
{
"name": "n-app",
"version": "1.0.0",
"description": "A Node application",
"dependencies": {
"jest": "^28.1.1",
"typescript": "^4.5.5",
"webpack": "^2.7.0"
}
}
Then npm install
will install jest, typescript, and webpack to the generated node_modules/
folder.
If you need to install a new package, then you need to specify the name like these examples:
# 👇 install react package
npm install react
# 👇 install react, react-dom, and axios packages
npm install react react-dom axios
You can install one or many packages with the npm install
command.
Integrity check failed error
When you have a package-lock.json
file in your project, then npm will check the integrity of the package you downloaded with the one specified in the lock file.
When the checksum of the package is different, then npm will stop the installation and throw the integrity check failed error.
The following is an example of the error:
npm ERR! code EINTEGRITY
npm ERR! Verification failed while extracting @my-package@^1.2.0:
npm ERR! Verification failed while extracting @my-package@^1.2.0:
npm ERR! Integrity check failed:
npm ERR! Wanted: sha512-lQ...HA==
npm ERR! Found: sha512-Mj...vg==
When this happens, you can fix the issue by verifying the cache:
When the command is finished, run npm install
again.
If you still see the error, then delete your lock file and clean the npm cache.
Run the following commands from your project’s root directory:
# 👇 remove the lock file
rm package-lock.json
# 👇 remove the node_modules folder
rm -rf node_modules
# 👇 Clear the npm cache
npm cache clean --force
# 👇 run npm install again
npm install
That should fix the issue with the integrity check.
For Windows only: Python not found
When running npm install
on Windows, you may see an error that says Can’t find Python executable as shown below:
> node-gyp rebuild
/n-app>node "..node_modulesnode-gypbinnode-gyp.js" rebuild
npm http 304 https://registry.npmjs.org/bcrypt
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python",
you can set the PYTHON env variable.
The node-gyp
module is a Node.js tool for compiling native modules written in C and C++. It requires Python to run properly.
Instead of installing Python by yourself, you can install the Windows Build Tools which has Python included.
This is because Windows also requires Visual Studio build tools to make node-gyp
run successfully.
If you install only Python, then you may find that you need the build tools later.
Please note that the latest version of Node.js for Windows installer already includes the build tools by default.
But if you can’t update your Node.js version yet, then installing the build tools manually should help you fix this error.
Conclusion
The npm install
command may fail to work because of many reasons.
When the command doesn’t work, you need to check the output first and see what specific error you have.
Try a Google search to fix the issue. When you don’t see a solution, try posting a new question at Stack Overflow mentioning the things you have tried to fix the issue.
Good luck resolving the issue! 👍
Пытаюсь установить npm пакеты, некоторые устанавливаются, а вот gulp-sass, gulp-scss, npm offline не устанавливаются. Хотя возможно остальные устанавливаются, потому что они были закэшированы.
Пакеты устанавливаются долго, по входящему трафику можно заметить, что, скорее всего файлы не скачиваются, а устанавливаются их кэша( отдельно пакетов для кэширования не устанавливал).
Npm выдает следующую ошибку
C:WDMbest.com>npm install gulp.sass
npm WARN package.json gulp-project@1.0.0 No repository field.
npm WARN package.json gulp-project@1.0.0 No README data
npm WARN package.json gulp-project@1.0.0 No license field.
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "gulp.sass"
npm ERR! node v4.4.3
npm ERR! npm v2.15.1
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! syscall connect
npm ERR! network connect ETIMEDOUT 192.168.0.1:8080
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! Please include the following file with any support request:
npm ERR! C:WDMbest.comnpm-debug.log
C:WDMbest.com>npm install offline-npm
npm WARN package.json gulp-project@1.0.0 No repository field.
npm WARN package.json gulp-project@1.0.0 No README data
npm WARN package.json gulp-project@1.0.0 No license field.
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "offline-npm"
npm ERR! node v4.4.3
npm ERR! npm v2.15.1
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! syscall connect
npm ERR! network connect ETIMEDOUT 192.168.0.1:8080
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! Please include the following file with any support request:
npm ERR! C:WDMbest.comnpm-debug.log
Переустанавливал Node, устанавливал 6ую, результат идентичный. Обновлял NPM до 3ей версии, такая-же ситуация… Сбрасывал прокси
>npm config set proxy null
>npm config set https-proxy null
Ума не приложу в чем дел, весь день вчера потратил… Раньше все работало идеально
…
I have installed nodejs latest on Windows 10 (64-bit) and the PATH is already setup. Now when i am trying to install any npm modules globally using npm install -g <packagename>
then I am getting the following error:
npm install -g <packagename>
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "<packagename>"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! 1961 == 0
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
The npm-debug.log shows:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'yo' ]
2 info using npm@3.10.10
3 info using node@v6.9.5
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData yo
8 silly fetchNamedPackageData yo
9 silly mapToRegistry name yo
10 silly mapToRegistry using default registry
11 silly mapToRegistry registry https://registry.npmjs.org/
12 silly mapToRegistry data Result {
12 silly mapToRegistry raw: 'yo',
12 silly mapToRegistry scope: null,
12 silly mapToRegistry escapedName: 'yo',
12 silly mapToRegistry name: 'yo',
12 silly mapToRegistry rawSpec: '',
12 silly mapToRegistry spec: 'latest',
12 silly mapToRegistry type: 'tag' }
13 silly mapToRegistry uri https://registry.npmjs.org/yo
14 verbose request uri https://registry.npmjs.org/yo
15 verbose request no auth needed
16 info attempt registry request try #1 at 3:40:19 PM
17 verbose request id 09fae89b96705683
18 http request GET https://registry.npmjs.org/yo
19 verbose stack AssertionError: 1961 == 0
19 verbose stack at ClientRequest.onConnect (C:Program Filesnodejsnode_modulesnpmnode_modulesrequestnode_modulestunnel-agentindex.js:159:14)
19 verbose stack at ClientRequest.g (events.js:291:16)
19 verbose stack at emitThree (events.js:116:13)
19 verbose stack at ClientRequest.emit (events.js:194:7)
19 verbose stack at Socket.socketOnData (_http_client.js:395:11)
19 verbose stack at emitOne (events.js:96:13)
19 verbose stack at Socket.emit (events.js:188:7)
19 verbose stack at readableAddChunk (_stream_readable.js:176:18)
19 verbose stack at Socket.Readable.push (_stream_readable.js:134:10)
19 verbose stack at TCP.onread (net.js:548:20)
20 verbose cwd C:wamp64wwwkvm-emart
21 error Windows_NT 10.0.14393
22 error argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "yo"
23 error node v6.9.5
24 error npm v3.10.10
25 error 1961 == 0
26 error If you need help, you may report this error at:
26 error <https://github.com/npm/npm/issues>
27 verbose exit [ 1, true ]
I do not understand the error in windows 10 while installing npm packages. Please let me know if this can be fixed.
I encountered the same problem and found the cause and a simple solution.
After installing nvm in bash a few months ago, I recently decided to give zsh and on-my-zsh a try. I followed the instructions and installed zsh and oh-my-zsh. When trying to run node
or npm
I got the errror:
zsh: /mnt/c/Program Files/nodejs/npm: bad interpreter: /bin/sh^M: no such file or directory
My investigations led me to the $PATH
variable. I then compared the output of echo $PATH
in bash and zsh. In bash the path included the nvm directory, in zsh this directory was not added to the path.
The reason for this difference is that nvm adds a snippet to the end of .bashrc
. In zsh .zshrc
is loaded instead and the snippet will not be executed.
The snippet looks like this:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
You can just copy these lines from .bashrc
to the end of .zshrc
, restart the shell, and the issue should be fixed if you have the same problem.