Should I install node.js on Ubuntu using package manager or from source?

只谈情不闲聊 提交于 2019-12-20 09:49:14

问题


Does anyone know if installing the latest build from source is a risky route to take? Should i just stick with the package manager?


回答1:


Current recommendations

  • Use nvm if you want to install with your user account. (I personally prefer this)
  • Follow the directions here to install via apt using a PPA.

Old Answer

Note: At the time of this writing I'm using Ubuntu 12.10.

There are a lot of ways to install node. I personally prefer to download the source of the latest stable build and just install it to ~/local (you do this by adding --prefix to the ./configure command as seen here. There really isn't any 'risk' in doing this as everything gets installed in a directory which is separated from the rest of your system. You can have a look at the node recipe in my system install scripts here. I regularly run my update_node.py script to upgrade my installation to the latest version.

Alternatively you can follow the directions here to install the latest stable version via the package manager. I haven't actually done that so I can't comment on how well it works.

What I wouldn't do is install node from the ubuntu universe packages. You'll end up with a very dated version (currently 0.6.19).

update 1/26/2013:

If you are interested in installing node with your user (non-root) account, I highly recommend reading this blog post. I skipped the ~/.npmrc step, but found that the ~/.node_modules symlink step was critial for getting require to work properly.

update 12/30/2014:

I have migrated to using linux mint and doing binary node installs. If you have any interest in writing your own installation scripts, you can find my current one here. Specifically have a look at what I'm doing in node.sh. The execute function is run during the first install so it does things like configure the paths in .bashrc. The install function is run by update-node.sh and is used to remove an existing installation and add a new one (the latest version or one specified by the user).

update 1/8/2016:

I just switched over to using nvm. Simply install the script and then run nvm install node to get the latest version. This seems like an excellent way to get node installed with your user account.




回答2:


another option is nvm (Node Version Manager) : https://github.com/creationix/nvm

bonus that it lets you easily switch between versions.




回答3:


Although I live in an .rpm, and not .deb realm, fpm can do both (needs Ruby installed). I have been able to package node.js from the latest stable source without any major difficulties. In your case, the following scenario may help:

./configure --prefix=/usr
make
mkdir -p /tmp/nodejs
make install DESTDIR=/tmp/nodejs
fpm -s dir -t deb -n nodejs -v 0.8.15 -p nodejs-0.8.15.deb -C /tmp/nodejs usr


来源:https://stackoverflow.com/questions/13845321/should-i-install-node-js-on-ubuntu-using-package-manager-or-from-source

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