PhpStorm 9 env: node: No such file or directory - node.js

I am using csscomb to prettify my .scss files. All was fine until I upgraded to PhpStorm 9.
csscomb runs without any problem from the terminal, but PhpStorm seems not to recognize node's path. When I run the command I get:
env: node: No such file or directory
Process finished with exit code 127
Any idea how to configure this ? Tried to edit path manually but failed.

To fix this you need to symlink the nodejs executable to node
sudo ln -s "$(which nodejs)" /usr/local/bin/node
If you installed node with nvm
sudo ln -s "$(which node)" /usr/local/bin/node

Restarting phpstorm fixed the issue. Still wondering why...

because not found nodejs, open & edit the lesscss program code first line, tell him where is the nodejs.

Related

Command not found even thought it is installed on Linux

I recently installed nodejs in a remote centos server following the instruction on https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-a-centos-7-server for installing a package from the node site, since the nodejs that was installed using yum was v 0.something.
The installation went well, and node seems to be working, but only when I execute
/usr/local/bin/node or npm for that matter.
If I try just
node or npm I get the following error:
-bash: /usr/bin/node: No such file or directory
This is a little strange because my PATH does have /usr/local/bin/, and if I do
which node
I get
/usr/local/bin
Here is a copy/paste from the server
[root#v468996 local]# echo $PATH;
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root#v468996 local]# /usr/local/bin/node -v
v11.5.0
[root#v468996 local]# which node
/usr/local/bin/node
[root#v468996 local]# node
-bash: /usr/bin/node: No such file or directory
Note I know I can just make symlink on /usr/bin, so I'm not really asking about that, I want to know why node won't run even though it is installed, and in a location within PATH
As #tink said, this seemed to be the shell remembering the old node location.

Installing Node.js - No such file or direktory

I have removed node.js on my CentOS. After that I was installing a new version node.js. Now I can't run the node.js:
-bash: /usr/local/bin/node: No such file or direktory
The only solution is to create a link
ln -s /usr/bin/node /usr/local/bin/node
Does anyone know why?
Recommend you to use nvm, very simple and can avoid many problems.
step one:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
step two:
nvm install stable
Check if successful:
node -v
I have solution for my problem. After re-login, everything is fine. I think the problem was somewhere in the ENV setup and reloaded after new login.

Cannot run NPM Commands

I've been using NPM on my machine (Windows 10), but recently ran into an issue. I currently have Node.js installed and get the following error while running any npm command.
Question: What is causing this error and whats the best way to resolve it.
Command:
$ npm install
Output/Error:
bash: /c/Program Files/nodejs/npm: /bin/sh^M: bad interpreter: No such file or directory
Not my solution, but this seemed to work for me. Appears that having the Windows folder structure in $PATH while using WSL2 was causing that parse error, but I'm not exactly sure why.
Go to your user root (cd ~)
Open .bashrc in your chosen editor (vi, nano, etc.)
Append to the end of the file: export PATH=$(echo "$PATH" | sed -e 's/:\/mnt[^:]*//g') # strip out problematic Windows %PATH%
Close and re-open all terminal windows
Source: https://hackmd.io/#badging/wsl2#Troubleshooting-PATH
Updated: Per Lh Lee's comment, I've updated the regex from s/:\/mnt.*//g to s/:\/mnt[^:]*//g as this avoids accidentally capturing anything extra after the problematic /mnt paths.
Whereas the first regex will match /mnt/c/blah:/other/thing, the new one will not.
Install nodejs/npm using nvm and it will not conflict with the one in windows.
The path for npm becomes (after installing using nvm) /home/ubuntu/.nvm/versions/node/v14.16.0/bin/npm
Read More about setting up your Node.js development environment with WSL 2
I did with these commands.
sudo apt update && sudo apt install curl -y
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.profile
nvm ls-remote
nvm install v15
node --version
This command with 78 upvotes:
# export PATH=$(echo "$PATH" | sed -e 's/:\/mnt[^:]*//g') # strip out problematic Windows %PATH%
causes problems with other commands such as the "code" command for VS Code. It manipulates the $PATH. The correct solution here is to use nvm:
sudo apt-get install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
nvm ls
nvm use 14
I had the same issue, I solved it by installing my dependencies on my Linux sub system as well. In my case it was just nodejs and npm.
Open Ubuntu terminal(Windows Sub system) I'm on windows 10...
sudo apt update
Now that the system is up to speed, let's do...
sudo apt install nodejs npm
(Do a variation of this suitable to you, I assume most are using nodejs though.)
My npm works now but still gives the error first. I mean it's not aesthetic at first, but my terminal on VS Code doesn't have the error first. Which is awesome!
TLDR: The linux subsystem doesn't have npm so download it there first.
Edit: formatting
It happened to me just now and all I had to do was exiting my wsl2 session and login in again.
Just faced the same issue, this issue happens because npm is installed on your windows machine but not on your WSL one. you just need to install npm on your linux machine then it will read the binary from linux not windows that's in case you want to use windows paths on your WSL. otherwise if you don't need the windows paths you can use thing adam mentioned by adding this into your path: PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') then refresh the shell with source ~/.bashrc
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.
If you already installed everything you need following this link https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl
just try restarting your VS Code and trying to run npm install.
I got this error when running npm install in a Visual Studio Code terminal, using Powershell. I switched to use a WSL2 terminal inside Visual Studio Code instead and it worked (tip - use npm i as a shorthand)
I am using Git Bash for cli
I my case my Antivirus has quarantined the C:\Program Files\Git\user\bin\sh.exe file, and that is why $ npm init was not working and showing this error:
bash: /c/Program Files/nodejs/npm: /bin/sh^M: bad interpreter: No such file or directory
When I restored that file it started working normally.
experienced this problem on my wsl2
not a fix but a workaround. unmounting the c drive resolve the issue.
umount /mnt/c
I had the same problem when I started using WSL, I solved it by using npm.cmd instead of npm command.

node -bash: /usr/sbin/node: No such file or directory

I am having this error with node. Running Debian 7 (Wheezy) a VPS.
I have this error if I for example run this command (in the directory of the .js)
node sell.js
or
screen node sell.js
They both don't work, because I am getting this error:
-bash: /usr/sbin/node: No such file or directory
Can somebody help me?
As in #Quentin's answer, the name of the executable may be incorrect. In many cases, what got installed was nodejs, not node. The line below creates a symbolic link that points to nodejs from where your system looks when you type node. It is a work-around - an alternative to simply typing nodejs
sudo ln -s /usr/bin/nodejs /usr/sbin/node
The Debian package for NodeJS is called nodejs and installed the executable /usr/bin/nodejs.
node is the wrong program, it is for ham radio operations, and your install of it appears to be broken anyway).
I ran the command:
sudo apt-get install nodejs-legacy
and nodejs worked again!
Maybe something wrong happened during your node's installing.
And system environment variable shows the command "node" referes to /usr/sbin/node .
Try download node linux binaries from official. Rename and put it in /usr/sbin after extracting the source. Of course you can put it in another folder as long as you update the system environment variables.

Ubuntu Sublime Text 2 Java Script compiling but not running

I'm setting up Sublime text 2 and running:
console.log("Hello!");
But all I'm getting in the console is "finished in [0.0]
My build system is:
{
"cmd": ["node", "$file"],
"selector": "source.js"
}
Any help would be greatly appreciated. This again is being done in Ubuntu.
The nodejs package for Ubuntu provides /usr/bin/nodejs, not /usr/bin/node. The node package, for amateur packet radio nodes, provides /usr/sbin/node, which is what your build system is running. It has nothing to do with Javascript, hence no output. There are two options (assuming you've already installed nodejs), and you can do one or both:
From the command line, run
sudo ln -s /usr/bin/nodejs /usr/local/bin/node
This will create a symlink to node that (I think, I'm not in Ubuntu at the moment) should be before /usr/sbin in your $PATH. Run echo $PATH to verify the order of your path.
Change your build system to run /usr/bin/nodejs instead of node. This will fix your immediate problem, but if you don't run the other command above you may have issues with Sublime's NodeJS plugin.
Good luck!

Resources