Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install error `not foundram Files/nodejs/npm: 3: /mnt/c/Program Files/nodejs/npm:`

Tags:

npm-install

I have installed Ubuntu Bash on Windows. I already have nodejs and npm on my windows machine at C:\Program Files\nodejs. In the bash shell in Windows, I am running a script which uses npm install command. The script is giving following error

: not foundram Files/nodejs/npm: 3: /mnt/c/Program Files/nodejs/npm: : not foundram Files/nodejs/npm: 5: /mnt/c/Program Files/nodejs/npm: /mnt/c/Program Files/nodejs/npm: 6: /mnt/c/Program Files/nodejs/npm: Syntax error: word unexpected (expecting "in") 
like image 964
Manu Chadha Avatar asked Aug 24 '17 05:08

Manu Chadha


People also ask

Does NVM install NPM?

How to install npm via Node. Now that nvm is installed, we're ready to do what we really wanted to do in the first place: install npm and Node on our system. It's not a bad idea to confirm nvm is installed properly, by running nvm -v . If the terminal shows you the installed version number, you're good to go!

How do I update NPM package manager?

Method 1: Using npm update command to update the node package manager. Method 2: Using npm@latest command to update the node package manager. Method 3: Using PPA repository (only for Linux). Method 4: Using cache cleaning & stable installing (only for Linux).


1 Answers

Note: Before following the steps below, first try to restart your shell.

You can install Node.js and NPM with your Windows PowerShell as well, so if you've done that it won't work properly for your Subsystem. That means you have to install it twice (Powershell and Subsystem) or decide on one thing.

If the preceding text, has not helped you, this is how to solve the problem:
Remove your current installations

sudo apt-get --purge remove node ("sudo apt autoremove node" if console is asking for it) sudo apt-get --purge remove nodejs 

Install node the right way. This is for version 14 (view current LTS version):

curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo apt-get install -y nodejs 

Then install build tools so you can install add-ons for npm later

sudo apt-get install -y build-essential 

Now you can type in

npm -v node -v Same thing: nodejs -v 

to check whether Node.js and NPM are installed correctly. If it shows nothing, restart the shell. If it still shows the same error, restart the WSL/ PC or try with sudo npm -v

Here are two links that may also help you.
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions https://github.com/nodesource/distributions/blob/master/README.md#debinstall

Also, take a look at the Node Version Manager (NVM). With it, you can easily switch back and forth between versions.

like image 189
Denis.Sabolotni Avatar answered Sep 19 '22 21:09

Denis.Sabolotni



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!