Reputation: 3391
I'm searching it in google on how to show the version of node js or how I'm gonna work with npm? If I do this
npm -v
even I already install it using brew install node
. The result is always
env: node: No such file or directory
I already do a lot of command to solve for it, but failed. these are the command that I already try:
sudo apt-get install nodejs-legacy
sudo ln -s /usr/local/bin/node /usr/bin/node
brew unlink node
brew link node
I can't start the task because of this. help me guys. This work before after I used this command brew link --overwrite node
. Now I have problem, i cant work anymore with npm. I'm really new about this. I don't have any idea now on how to fix this.
Update
I already get the list using npm list
command. I also get the idea here link but when I npm install
inside the project. I alwayst get this "result env: node: No such file or directory",even I command npm -v
but If i command it outside my project. It work the npm -v
Upvotes: 159
Views: 299885
Reputation: 11
If all of these will answers do not work try using
npm install -g ts-node
this will work for you.
Upvotes: 1
Reputation: 175
i use n
node version manager. I got this error when i switched to a specific node version (16.20.2). I then tried switching to another version and it was fine. so i deleted the problematic version: sudo n uninstall 16.20.2
and tried installing it again sudo n install 16.20.2
and everything was peachy agin.
Upvotes: 0
Reputation: 1990
I tried couple methods here, but later I recalled I'm some kind of admin :) so I just linked files like so (you version and path might be different and assuming node is installed already):
ln -s /usr/local/Cellar/node@14/14.21.3_1/bin/node /usr/local/bin/node
ln -s /usr/local/Cellar/node@14/14.21.3_1/bin/npm /usr/local/bin/npm
Upvotes: 0
Reputation: 28800
The issue was caused by no node application being installed.
When I run the command:
node --version
I get no node version:
zsh: command not found: node
I ran the following commands to fix it:
brew uninstall --force node
brew uninstall --force npm
brew doctor
brew install nvm
brew install yarn
brew install node
Upvotes: 4
Reputation: 41
Kept getting this error, found it it's because NVM wasn't using any version of node. I didn't set this but after using these commands it seemed to fix the error
nvm install lts/*
nvm use lts/*
Upvotes: 0
Reputation: 1
just run cmd:
% npm
before
% npx install-peerdeps --dev eslint-config-airbnb
on Mac m1 pro
Upvotes: 0
Reputation: 3490
Just did an update on my Mac OS which switched my .bash
to /zshrc
. Here is what I added to my ~/.zshrc
file:
export NVM_DIR="/Users/< my name >/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # this loads nvm
Then I did a $ source ~/.zshrc
and it refreshed those values.
Double checked my work with nvm --version
and it was all good.
Upvotes: 0
Reputation: 19
For mac user using the package manager homebrew:
-brew uninstall node
-brew uninstall npm
-brew doctor
-brew link node
-node -v (to check node version)
That's all you need.
Upvotes: 2
Reputation: 99
I also face this issue on mac. I had installed node using brew. I was able to resolve the issue by following these steps:
Upvotes: 0
Reputation: 406
If you just installed/modified node and if intellij/webstorm or your shell is throwing this error, it's because it has not sourced the environment variables, try restarting the IDE/shell.
Upvotes: 0
Reputation: 161
Thanks to this forum. Sharing my notes below.
macOS Monterey version 12.2.1 Chip Apple M1
$ brew uninstall --force node
$ brew uninstall --force npm
$ brew install node
$ brew link --overwrite node
$ brew doctor
$ brew cleanup
$ nvm --version
// 0.35.3
$ nvm use stable
// Now using node v17.6.0 (npm v8.5.1)
$ node -v
// v17.6.0
$ npm -v
// 8.5.1
Upvotes: 16
Reputation: 21
Working on MacOSx, maven exec not willing to execute a shell script that I could manually execute with desired result. Gave me the same error, solved it as well with
export PATH="$PATH:"/usr/local/bin/ at the beginning of the script
Upvotes: 2
Reputation: 2683
I was using fish shell and encountered this problem on my m1 macbook air.
omf install nvm
~/.config/fish/functions/nvm.fish
vim ~/.config/fish/functions/nvm.fish
function nvm
bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv
end
nvm install node
It worked for me after that, :) hopefully it does for you too
credit https://eshlox.net/2019/01/27/how-to-use-nvm-with-fish-shell
Upvotes: 0
Reputation: 650
For me, this error occurred when I tried to install a package with sudo npm. This fixed it:
sudo env PATH="$PATH:/usr/local/bin/" npm <rest of command>
Upvotes: 3
Reputation: 6412
I get this error running npm start
through PyCharm on Mac. For that the answer is to start PyCharm from the Terminal with open -a '/Applications/PyCharm.app/'
. See https://stackoverflow.com/a/34017083/733092.
For Pycharm Professional, starting from the command line is different. Get the JetBrains Toolbox app, go to Settings, Generate Shell Script, and it will create a ~/pycharm_shell_scripts
for you to run.
Upvotes: 2
Reputation: 1435
If you're switching from bash to oh my zsh
, you will need to add nvm
's path into the zshrc file.
@Zgpeace's answer here helped solve my issue (on IOS):
nano ~/.zshrc
export NVM_DIR=~/.nvm
Ctrl+X
--> Yes
.source $(brew --prefix nvm)/nvm.sh
nvm --version
.0.37.2
Upvotes: 21
Reputation: 1087
It was nvm changing paths for me, this fixed it:
nvm use stable
Upvotes: 7
Reputation: 2952
NOTE: Only mac users!
curl -ksO https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh
chmod +x ./uninstall-node.sh
./uninstall-node.sh
rm uninstall-node.sh
Or you could check out this website: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
if this doesn't work, you need to remove node via control panel or any other method. As long as it gets removed.
If you use nvm
, you can use:
nvm install node
You can already check if it works, then you don't need to take the following steps with: npm -v
and then node -v
if you have nvm
installed:
command -v nvm
sudo npm uninstall npm -g
Or, if that fails, get the npm source code, and do:
sudo make uninstall
If you have nvm
installed, then use: nvm uninstall npm
npm install -g grunt
Upvotes: 95
Reputation: 518
I re-installed node through this link and it fixed it.
I think the issue was that I somehow got node to be in my /usr/bin
instead of /usr/local/bin
.
Upvotes: 3
Reputation: 1591
I got such a problem after I upgraded my node version with brew. To fix the problem
1)run $brew doctor
to check out if it is successfully installed or not
2) In case you missed clearing any node-related file before, such error log might pop up:
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built.
node
3) Now you are recommended to run brew link command to delete the original node-related files and overwrite new files - $ brew link node
.
And that's it - everything works again !!!
Upvotes: 11
Reputation: 1035
I was getting this env: node: No such file or directory
error when running the job through Jenkins.
What I did to fix it - added export PATH="$PATH:"/usr/local/bin/
at the beginning of the script that Jenkins job executes.
Upvotes: 23
Reputation: 7072
Let's see, I sorted that on a different way. in my case I had as path something like ~/.local/bin
which seems that it is not the way it wants.
Try to use the full path, like /Users/tobias/.local/bin
, I mean, change the PATH
variable from ~/.local/bin
to /Users/tobias/.local/bin
or $HOME/.local/bin
.
Now it works. 🙀🙀🙀
Upvotes: 2
Reputation: 2692
I solved it this way:
$ brew uninstall --force node
$ brew uninstall --force npm
after it
$ brew install node
which suggested me to overwrite simlinks
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/doc/node/gdbinit
Target /usr/local/share/doc/node/gdbinit
already exists. You may want to remove it:
rm '/usr/local/share/doc/node/gdbinit'
To force the link and overwrite all conflicting files:
brew link --overwrite node
after executing
$ brew link --overwrite node
everything worked again.
Upvotes: 212