我想在命令行上获取node.js的版本 - 我希望运行如下命令:
node -version
Run Code Online (Sandbox Code Playgroud)
但这不起作用.有人知道命令行是什么吗?(即不是REPL)
由于名称与另一个包冲突,nodeUbuntu上的NodeJS解释器名称()已重命名为nodejs.这是自述文件.Debian说:
Node.js解释器命令的上游名称是"node".在Debian中,解释器命令已更改为"nodejs".
这样做是为了防止命名空间冲突:其他命令在其上游使用相同的名称,例如来自"node"包的ax25-node.
必须将调用Node.js作为shell命令的脚本更改为使用"nodejs"命令.
但是,使用nodejs会破坏使用安装包npm.程序包安装失败,并显示以下错误:
Run Code Online (Sandbox Code Playgroud)sh: 1: node: not found npm WARN This failure might be due to the use of legacy binary "node" npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian
如何让npm了解nodejs已安装在系统上,但解释器名称有所不同?
通过npm 安装gulp.js后,从安装它的同一目录no command 'gulp' found运行gulp命令时收到错误.
在node_modules/.bin/目录下查看时,我可以在gulp那里看到可执行文件.
我的npm安装有问题吗?
这里有一个总节点noob.我一直在尝试设置一个示例节点应用程序但每次尝试运行时都会弹出以下错误:
节点应用
Failed to load c++ bson extension, using pure JS version
events.js:72
throw er; // Unhandled 'error' event
^
Error: failed to connect to [#$%67890 :27017]
at null.<anonymous> (/home/thejazeto/code/nodejs/authen/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:553:74)
at EventEmitter.emit (events.js:106:17)
at null.<anonymous> (/home/thejazeto/code/nodejs/authen/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
at EventEmitter.emit (events.js:98:17)
at Socket.<anonymous> (/home/thejazeto/code/nodejs/authen/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:512:10)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:830:16
at process._tickCallback (node.js:415:13)
Run Code Online (Sandbox Code Playgroud) 我最近浏览了我的ubuntu 16.04中的节点版本,当使用node -v命令时它显示我的版本6.9.1但是当nodejs -v它在使用此命令之前显示6.9.2 时使用了命令npm update.
现在,什么是在这些差异node -v和nodejs -v?以及如何更新到节点/ nodejs的最新LTS版本?
我正在尝试为node.js创建一个可在多个环境中工作的脚本.特别是对我来说,我在OS X和Ubuntu之间来回切换.在前者中,Node安装为node,但后者是nodejs.在我的脚本的顶部,我可以:
#!/usr/bin/env node
Run Code Online (Sandbox Code Playgroud)
要么
#!/usr/bin/env nodejs
Run Code Online (Sandbox Code Playgroud)
我宁愿让脚本作为任一环境的可执行文件运行,只要安装了节点而不是让一个或另一个必须指定命令(./script-name.jsvs. node script-name.js).
是否有任何方法可以指定备份hashbang或者在node.js的任何一种情况下都兼容?
这是我在ubuntu 14.04 LTS中安装nodejs的方式:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get install nodejs
Run Code Online (Sandbox Code Playgroud)
当我用这个检查节点版本时:
node -v
Run Code Online (Sandbox Code Playgroud)
我明白了
v0.10.37
Run Code Online (Sandbox Code Playgroud)
但最新版本是4.2.6和5.5.0.我如何获得最新版本或更新版本?
我正在设置node.js以便使用像Meteor,Derby或Ember这样的框架,但是我很早就遇到了一些问题.按照这些说明(http://www.nodebeginner.org),我安装了node,创建了一个简单的helloworld.js文件,然后在终端中运行了这个命令:
node path/to/file/helloworld.js
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
-bash: node: command not found
Run Code Online (Sandbox Code Playgroud)
我尝试导航到目录,然后只是运行:
node helloworld.js
Run Code Online (Sandbox Code Playgroud)
但得到同样的错误.我对node.js完全不熟悉并且不知所措.
运行OS X 10.7.5和最新版本的节点.
将我的系统从Ubuntu 13.04迁移到13.10,我已经安装了Ubuntu Logiteque提供的最新nodejs软件包(这是自动软件包安装程序的frech名称,不知道英文是否相同......).
尝试使用命令安装yeoman:
npm install -g yo
Run Code Online (Sandbox Code Playgroud)
给我以下错误:
npm http 200 https://registry.npmjs.org/is/-/is-0.2.7.tgz
/usr/local/bin/yo -> /usr/local/lib/node_modules/yo/cli.js
> yo@1.1.2 postinstall /usr/local/lib/node_modules/yo
> node ./scripts/doctor
sh: 1: node: not found
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! yo@1.1.2 postinstall: `node ./scripts/doctor`
npm ERR! `sh "-c" "node ./scripts/doctor"` failed with 127
npm ERR!
npm ERR! Failed at the yo@1.1.2 postinstall script.
npm ERR! This is most …Run Code Online (Sandbox Code Playgroud) node.js ×10
ubuntu ×3
javascript ×2
npm ×2
command-line ×1
dependencies ×1
express ×1
gulp ×1
mongoose ×1
shebang ×1
shell ×1
ubuntu-13.10 ×1