Express.js: None. Such a file or directory

I installed node with apt-get install nodejs . Then I installed npm using apt-get install npm . Now when I try to run express , I get

 $ express /usr/bin/env: node: No such file or directory 

How to fix this error?

+45
ubuntu fedora
Feb 16 '13 at 20:19
source share
5 answers

Ubuntu has two packages with similar names, node and nodejs.

node does this

Description-ru: amateur packet radio node program. The node program accepts TCP / IP and packet radio network connections and provides users with an interface that allows them to establish gateway connections to remote nodes using various amateur radio protocols.

nodejs does this

Description-ru: Node.js server-side javascript engine Node.js is similar in design and depends on systems like Ruby Event Machine or Python Twisted. It takes the event model a little further - it presents the event loop as a language construct, and not as a library. Node.js comes with several useful libraries for working with server tasks: System, Events, Standard I / O, Modules, Timers, Child Processes, POSIX, HTTP, Multipart Parsing, TCP, DNS, Assert, Path, URL, Query Strings.

Fedora also follows a similar package naming scheme. Because of this, the binary in nodejs had to be renamed to nodejs from the original node . However, this is not technically kosher: and most nodejs programs (and libraries installed with npm) assume that the binary node is node . If you want to get around this, the easiest way is simply to symbolically combine the two. If you take this route, do not install the node package, which handles the material of the amateur radio package.

 sudo ln -s /usr/bin/nodejs /usr/local/bin/node 

Alternatively, in the case of node, I would suggest using n and not installing node . Just install npm (which will install node), then uninstall npm and then tell apt to clear it. To do this, simply run

 sudo apt-get install npm sudo npm install -gn sudo n latest sudo apt-get --purge remove npm sudo apt-get autoremove 

There are other binary distribution managers that even work from a shell script like nvm , but I personally prefer n . Think of n as an approach to only one thing: the binary binary node, which it installs in /usr/local/bin .

Why remove npm? Were not. apt-get --purge remove can only remove things that are installed by the package manager. n latest works outside the package manager. If you do this, there will be two npms,

  • installed by the distribution (Debian / Ubuntu) using apt-get .
  • version installed n n latest .

It makes no sense to have an older version of the distribution. And, even worse, if this version works, it could potentially install it elsewhere and have Debian changes in it that would install the Debian installation directories. It is better to use either / or not both.

+102
Feb 16 '13 at 20:19
source share

you must install the nodejs-legacy package which has a link from / usr / bin / node to / usr / bin / nodejs

$ sudo apt-get install nodejs-legacy

+21
May 05 '13 at 16:23
source share

In my case, this was because in my PATH environment variable I had "~ / progs / node / bin /" and "~" did not seem to be allowed by env ... replacing it with the full full path (" / home / myuser / node / bin ") solved my problem.

+4
Mar 13 '13 at 22:35
source share

This decision

 export PATH="$HOME/opt/nodejs/bin:$PATH" 

solved this problem for me (it should work if $ HOME variable is set). It also allows me to avoid hard-coding the path to my home directory (e.g. so that I can reuse my .bash_profile with different accounts / servers if I need to)

+1
Oct. 19 '15 at 17:59 on
source share

do it in cmd

 sudo apt-get install nodejs-legacy chmod your folder 700 (optional) 
0
01 Sep '14 at 9:49
source share



All Articles