what are the differences between node.js and node?

柔情痞子 提交于 2019-11-26 08:55:20

问题


I have installed node.js in my machine (linux mint 15), when I run node example.js, it says:

The program \'node\' can be found in the following packages:
 * node
 * nodejs-legacy
Try: sudo apt-get install <selected package>

So what are the differences between node and nodejs? I had both node.js and node installed previously, but when I run node example.js, the web server doesn\'t start at all. So I deleted node and kept node.js.


回答1:


The package node is not related to node.js.

nodejs is what you want, however it is arguably better to have the command be called node for compatibility with scripts that use #!/usr/bin/env node.

You can either just create a symlink in your path:

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

Or you could install nvm and then use it to install the latest version of node.js:

nvm install stable

I prefer the nvm method, as it allows you to sudo apt-get remove nodejs, and then manage which version of node you're using yourself. You can also have multiple versions of node.js installed and use nvm use to easily switch between them.

I also like to add a line to the bottom my .bashrc like: nvm use stable > /dev/null. That will automatically use the latest version you have installed.

To update your node version to the latest stable: nvm install stable. Every time you do this you will need to install any npm packages that you had installed globally if you want to continue using them.

To switch to an old version just run nvm use <version>, or, if you don't have the old version installed already: nvm install <version>.




回答2:


This answer is just to tell you the difference between node and nodejs packages on Debian OS.

node

  • Amateur Packet Radio Node program.
  • Package details link: https://packages.debian.org/source/wheezy/node

nodejs

  • Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
  • Package details link:
    • https://packages.debian.org/source/sid/nodejs


来源:https://stackoverflow.com/questions/20057790/what-are-the-differences-between-node-js-and-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!