4

I am running latest stable windows with bash on Ubuntu running through cmder wslbridge (i tried running directly through bash but same errors). Moving to my windows based react-native folder and trying to run some cli like npm run android , react-native run-android , gradlew clean is always producing errors;

enter image description here

enter image description here

while surprisingly some other commands like npm start work properly...

which npm print out; /usr/local/bin/npm

i have npm installed on windows and inisde Ubuntu and whereis npm produce this

enter image description here

I am really confused here; when running npm commands inside the bash onto windows folders which npm should be triggered? the windows or WSL one?!

I've tried a lot of suggested solution, but nothing seems to be working...

2
  • @Biswapriyo As mentioned i am using Cmder with bash WSL bridge, and the color theme is only oh-my-zsh... but will give pure cmd a try! edit: tried it in cmd.exe; same exact errors! Commented Jul 27, 2018 at 16:28
  • Did you edit the gradlew in Windows? There are some errors with carriage return used in Windows. Try to change the end-of-line from \r\n to \n. Use the sed command with that gradlew file: unix.stackexchange.com/questions/138472 Commented Jul 27, 2018 at 19:13

1 Answer 1

2

As you have said you are unsure what is actaully running when you run the commands. if you run the following commands it might make it clear as to what is actually running.

➜  ~ whereis npm
npm: /usr/local/bin/npm /home/damo/.nvm/versions/node/v8.11.1/bin/npm /mnt/c/Program Files/nodejs/npm /mnt/c/Program Files/nodejs/npm.cmd

➜  ~ which npm
/home/damo/.nvm/versions/node/v8.11.1/bin/npm

➜  ~ npm --version
6.4.1

➜  ~ sudo find / -name npm
/home/damo/.npm/10.52.63.39_4783/npm
/home/damo/.npm/npm
/home/damo/.nvm/versions/node/v10.4.1/bin/npm
/home/damo/.nvm/versions/node/v8.11.1/bin/npm
/home/damo/.oh-my-zsh/plugins/npm
/mnt/c/Program Files/nodejs/node_modules/npm
/mnt/c/Program Files/nodejs/node_modules/npm/bin/npm
/mnt/c/Program Files/nodejs/npm
/mnt/c/Users/stangerd/AppData/Roaming/npm

➜  ~ echo $PATH
/home/damo/.nvm/versions/node/v8.11.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files/cmder/vendor/conemu-maximus5/ConEmu/Scripts:/mnt/c/Program Files/cmder/vendor/conemu-maximus5:/mnt/c/Program Files/cmder/vendor/conemu-maximus5/ConEmu:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/HashiCorp/Vagrant/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/nodejs:/mnt/c/Program Files/Beyond Compare 4:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Users/    stangerd/AppData/Roaming/npm

➜  ~ nvm use 10
Now using node v10.4.1 (npm v6.1.0)

➜  ~ echo $PATH
/home/damo/.nvm/versions/node/v10.4.1/bin:/usr/local/sbin:/usr/local/bin:........

You can see that for me i also have many versions of npm, but that its my WSLs current nvm version that is being used (shown by running which npm). This is because when the path is searched the first one found will be used. the first instance of npm in all the folders in my path is in /home/damo/.nvm/versions/node/v8.11.1/bin. Notice that when using nvm the path will be changed when switching node versions and that conveniently it puts this new path on the front of all the existing path folders.

Its also worth checking the alias set as this gets evaluated before the path is even queried. Just run alias to get a list.

Hope that this helps to find what is actually running. I'm interested to hear how you get on.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.