Express.js:否这样的文件或目录 [英] Express.js: No Such file or directory
问题描述
我用apt-get install nodejs
安装了节点.然后我用apt-get install npm
安装了npm.现在,当我尝试运行express
时,我会得到
I installed node with apt-get install nodejs
. Then I installed npm with apt-get install npm
. Now when I try to run express
I get
$ express
/usr/bin/env: node: No such file or directory
如何解决此错误?
推荐答案
Ubuntu中有两个名称相似的软件包,分别是 node 和 nodejs .
There are two package in Ubuntu that have similar names, node and nodejs.
node
做到了,
说明:业余分组无线节点程序.该节点程序接受TCP/IP和分组无线网络连接,并为用户提供一个接口,使他们可以使用各种业余无线协议与远程主机建立网关连接.
Description-en: Amateur Packet Radio Node program. The node program accepts TCP/IP and packet radio network connections and presents users with an interface that allows them to make gateway connections to remote hosts using a variety of amateur radio protocols.
nodejs
这样做
描述:基于Node.js事件的服务器端JavaScript引擎Node.js在设计上与Ruby的Event Machine或Python的Twisted之类的系统相似,并受其影响.它使事件模型更进一步-将事件循环作为一种语言构造而不是作为一个库来呈现. Node.js捆绑有一些有用的库来处理服务器任务:系统,事件,标准I/O,模块,计时器,子进程,POSIX,HTTP,多部分解析,TCP,DNS,断言,路径,URL,查询字符串.
Description-en: Node.js event-based server-side javascript engine Node.js is similar in design to and influenced by systems like Ruby's Event Machine or Python's Twisted. It takes the event model a bit further - it presents the event loop as a language construct instead of as a library. Node.js is bundled with several useful libraries to handle server tasks : System, Events, Standard I/O, Modules, Timers, Child Processes, POSIX, HTTP, Multipart Parsing, TCP, DNS, Assert, Path, URL, Query Strings.
Fedora也遵循类似的软件包命名方案.因此,必须将nodejs
中的二进制文件从原始node
重命名为nodejs
.但是,从技术上讲,这不是可理解的:大多数nodejs程序(以及随npm安装的库)都假定节点二进制文件为node
.如果您想解决这个问题,最简单的方法就是将两者符号链接在一起.如果采用这种方式,请不要安装用于处理业余分组无线电的node
软件包.
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 isn't technically kosher: and most nodejs programs (and libraries installed with npm) assume that the node binary is node
. If you want to get around this the easiest way is just symlink the two together. If you take this route, don't install the node
package which handles the Amateur Packet Radio stuff.
sudo ln -s /usr/bin/nodejs /usr/local/bin/node
或者,对于节点,我建议使用 n
而不安装node
.只需安装npm(将安装节点),然后删除npm,然后告诉apt清理它即可.为此,只需运行
Alternatively, in the case of node, I'd suggest using n
and not installing node
. Just install npm (which will install node), then remove npm, then tell apt to clean it up. To do this, simply run
sudo apt-get install npm
sudo npm install -g n
sudo n latest
sudo apt-get --purge remove npm
sudo apt-get autoremove
还有其他二进制发行版管理器,甚至可以使用像nvm
这样的shell脚本工作,但我个人更喜欢n
.认为n
就像是只适合一件事的工具:它安装到/usr/local/bin
的节点二进制文件.
There are other binary distro managers that even work from a shell script like nvm
but I personally prefer n
. Think of n
like an apt for just one thing: the node binary which it installs to /usr/local/bin
.
为什么要删除npm?不是. apt-get --purge remove
只能 删除软件包管理器安装的内容. n latest
在程序包管理器之外工作.如果执行此操作,则有两个npm,
Why are removing npm? We're not. apt-get --purge remove
can only ever remove things installed by the package manager. n latest
works outside of the package manager. There are two npms if you do this,
-
发行版(Debian/Ubuntu)使用
- 版本.
- 版本由
n latest
安装.
apt-get
安装的- version installed by the distro (Debian/Ubuntu) using
apt-get
. - version installed by
n latest
.
使用发行版的旧版本毫无意义.而且,甚至更糟的是,如果该版本有效,它可能会安装到其他位置,并在其中进行Debian修改,以采用Debian安装目录.最好同时使用一个或多个,但不要同时使用.
No point in having the distro's older version. And, even worse, if that version works it can potentially install to a different location and have Debian modifications in it that assume Debian install directories. It's better to use either/or but not both.
这篇关于Express.js:否这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!