-
Notifications
You must be signed in to change notification settings - Fork 838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue running npm command #1512
Comments
Interesting, I wonder why all of the paths that are being stat'ed have a '\r' character at the end... I suspect this is coming from some config file that needs to be converted to Unix line endings (probably /mnt/c/Program Files/nodejs/npm). How did you generate this file? Could you try running |
Standard NPM install as far as I'm aware. Got this fun error back:
|
Maybe run bash.exe elevated? The Program Files directory might be locked down to non admin users. |
Ah, that was it all right. Got this error now:
But I'm thinking that may be a quirk of windows<->linux? |
Why just not use NPM from ubuntu side? It works perfectly fine. Also, NVM works really well here. |
The honest answer was I was in bash shell by accident when I ran the initial command, just figured I should report it. |
Just hit this issue as well - haven't found a good fix yet either. If you end up finding one that works - please post here - I will as well. |
I did the node installer on Windows 10, restarted my computer, and tried running NPM with the same exact trace as @benhillis - I'm using Bash for Ubuntu via developer mode. This feedback:
Occurs after any usage of |
Looks like some sort of conflict between Node on Windows and Node installed inside of the subsystem. I installed both (Node on Windows to get Hyper operational) and then node on the subsystem for everything else - I kind of assumed that because the node on the subsystem was the binary being used (if I did a where node) that I wouldn't run into these problems. No dice, get the same error as everyone else |
@chrisdhanaraj -- could you confirm the same for npm? Specifically, if you do For what it's worth, I have npm installed in both Windows and WSL, and I don't experience this problem. For me:
|
So I now simply installed the most recent version of node like on ubuntu:
(the newer node version also include npm already) More details here: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions Now this is used inside hyper.js/bash. The windows installation is still there but basically ignored by bash. |
I was having this issue when running In my I have this script to automatically go to if test -t 1; then
exec zsh
fi I installed
But I was still running into the same error because my # If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH Which I changed to the default Ubuntu one export |
Unfortunately, the very first thing I tried using wsl bash was
The error message really sucks. I'm guessing this is probably caused by to the space in I'm a Windows developer through and through, but IMHO allowing spaces in directory names was one of the bigger mistakes in the Windows NT. Allowing spaces was surpassed only by including spaces in the normal names of system folders. Have I gotten burned by that again? Is it possible to "fix" this by patching up the UNIX version of the PATH environment variable using quotes or something? |
hi y'all, here's how i got my stuff working. i'm on ubuntu for windows 10 (on a windows VM--i don't think the VM part matters though). i was getting the same errors as @RichiCoder1 $ npm -v
: 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") i have node installed for windows (off the nodejs site). i kept it around, and in addition i followed @mrtopf's install instructions $ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs then i made some changes to my PATH in my
and sourced it what i'm doing up there is telling bash where & in what order to look for my commands, separated by you should $ which npm
/usr/bin/npm so i added $ whereis npm
npm: /usr/bin/npm /mnt/c/Program Files/nodejs/npm /mnt/c/Program Files/nodejs/npm.cmd bash will use |
Hello, I just had this issue, and I didn't want to have a second npm install. Next I created a "Program Files/nodejs/node" script:
That translates "node /mnt/c/Users/..../file.js" into "node.exe c:\users....\file.js" |
@phucanhapril your |
@phucanhapril you saved me a lot of time thanks! 👍 |
Just restarting the command promp after the node installation on the bash resolved this error for me. |
@Georg-W now I feel stupid. Good call! |
Running with sudo worked for me, when attempting to install less:
|
I've found out what causes:
If you open
you will see the probably somebody upstream messed up and forgot to turn on I'm not sure if there's any way besides using the Windows Installer to install node for now. Edit
I will test and see if this works |
I uninstalled node from WIndows and then installing nvm worked fine inside of Bash for Windows |
@phucanhapril solution worked for me on WSL. I also have npm installed alongside on Windows. Thanks for the help. |
@phucanhapril , correct me if I'm wrong but your solution is to install a newer NPM in the Bash environment correct? Is there a way to maintain the node installed in Windows, while making it work on Bash too? |
Hi @zaidrashid I can confirm that npm is installed in Windows and WSL. I followed @phucanhapril process. If I open a Windows terminal and call npm I get: Then I bash into WSL and call npm and get: Am realizing now that I may have some issues with versions, but they do appear to be working independently. |
Hi, i used @felipemanga solution but made modification in npm srcipt: |
Hello @mfominov, I also used @felipemanga 's script but could not get the npm script to work. Here is the full npm script:
node -v works great, however, this is the output that I am getting for npm -v Error: EINVAL: invalid argument, uv_pipe_open |
I fixed it by doing
|
I found out this was due to me trying to run an older version of Node/npm. I fixed it by updating my node version to the latest following this thread https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version |
I think changing $PATH manually is kind of ugly, so I choose to close the interoperability of WSL with Windows. After doing this, $PATH has turned really simple, away from conflicts. <3 |
This did it for me. Thank you! |
I am using Ubuntu 18.04 subsystem for windows 10 and this fixed it for me. Thank you very much! |
@Georg-W can I buy you a beer man? lol all this freaking out all this searching. I think it could of been a combination of you and @abhijithvijayan |
Glad it helped. |
Hello is easy, if you Using Ubuntu on WSL (zsh/hyper) First: Remove and Install Again Node
Second: Open and editthe .zshrc from the oh-my-zsh. Find the line
And replace with:
The last step is to reset your config: Test if this post works for you.
|
Ran into this wsl npm headache today. If other solutions did not work for you, this is what I did.
1- optional.. UNINSTALL ubuntu wsl but don't forget to Run history first and back up your files.
Run this to update your terminal
11- which node Twitter is the best way to reach me. I think those are all the steps, but ping me @mabrafoo if needed. |
Hello from the future, you are an absolute legend! this fixed an issue with npm on WSL which I had been trying to resolve for days. I followed your instructions, and tried |
Did anybody find a solution for this? I would like to just use my Node installation on Windows if that is possible. That would be the most elegant and efficient solution. |
I just used |
Oh my god, really appreciate, Just 1 line of code, solved my problem |
I had this problem, caused by not running with sudo. try to run with administrator privileges. |
Installing Solves the (will see how many other problems I will encounter along the way) |
I met this problem in WSL and my directory is 'C:\Program Files\nodejs'. When I moved nodejs directory to C (C:\nodejs), npm works well. |
YOU FUCKING GENIUS GENIUS |
All of the replies above seem to be installing First of all note that since the Windows 10 Creators Update (build 1703, April 2017), we can natively run The problem is that all of these are The way I go around this is by running:
You will notice that with your We must create alias for these again if you want to use them through Full solution:
The reason we need the After restarting your terminal, you should be able to run |
this one worked for me |
I know this is an older thread but I tried both run as admin AND super user... and both worked... then I thought I wanted to double check so I removed SU and it still worked... so that left "run as admin", so I closed ubuntu app and reopened it normally and it STILL worked. So without uninstalling and reinstalling, my guess is maybe you had to restart the app or maybe source would work?? i dunno, but now npm works just fine without sudo and without running as admin... |
People are clobbering the windows The reason it works for you is because |
It was just an experiment i tried. And i never said anything about adding too the path varriable..bc i didnt do that. I'm just saying that after installing.. Restart the Cli |
Just add That was the only method that worked for me |
Adding |
fixed @EduMOliveira Thank you so much! |
I installed node using From here node was available in the terminal, but running Running Run |
When running "npm" from bash, I get the following error:
Your Windows build number
Steps / All commands required to reproduce the error from a brand new installation
Strace of the failing command
npm
The text was updated successfully, but these errors were encountered: