更新node版本
2017-09-04 14:41
190 查看
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
http://www.hostingadvice.com/how-to/update-node-js-latest-version/
We’re covering all your bases with updating Node on Linux-based operating systems, but Option 1 is by far our most recommended method for simplicity and effectiveness. If extenuating
circumstances prevent you from going the Node Version Manager route, read on for instructions on updating Node through package managers or binary packages.
Node Version Manager, or nvm, is far and away the best method to updating
Node. You’ll need a C++ compiler, as well as the build-essential and libssl-dev packages. Run an update first, then get the packages:
To install or update nvm, you can get the install script by using cURL:
You’ll have to close and reopen the terminal first, but you can verify a successful installation by using command -v nvm.
The command will output nvm if everything worked.
Once you’re set up, installing updated versions of Node is a breeze. You can check what versions are currently installed with nvm lsand
see what is available to install by using nvm ls-remote.
Download, compile, and install newer versions of Node with nvm install #.#.#,
obviously substituting the #s for the Node version you want. You can tell nvm which version to use in each new shell with nvm use #.#.# and
set a default with alias: nvm alias default node.
If nvm isn’t for you, a package manager is your next best bet. Node package manager,
or npm, helps you discover, share, and use code, along with managing dependencies.
Node comes with npm pre-installed, but the manager is updated more frequently than Node. Run npm -v to
see which version you have, then npm install npm@latest -g to
install the newest npm update. Run npm -v again
if you want to make sure npm updated correctly.
To update Node, you’ll need npm’s handy n module. Run this code to clear
npm’s cache, install n, and install the latest stable version of Node:
To install the latest release, use n latest.
Alternatively, you can run n #.#.# to
get a specific Node version.
Let’s be honest — you probably don’t want to go this route. If you’re desperate, however, go to the official Node.js downloads
page to get the 32-bit or 64-bit Linux binary file. You can download the file from a browser, but we prefer using the console. Keep in mind, the specific Node version might change as updates are released.
To unpack the file, you’ll need xz-utils; to install it, run sudo apt-get install xz-utils.
Next, use this code to install the binary package in usr/local:
Now that you have Node and npm, consider giving Option
2 a try for the next update.
The Node.js downloads page includes binary packages for Windows and macOS
— but why make your life more difficult? The pre-made installers — .msi for Windows and .pkg for macOS — make the installation process unbelievably efficient and understandable. Download and run the file, and let the installation wizard take care of the rest.
With each downloaded update, the newer versions of Node and npm will replace the older version.
Alternatively, macOS users can use the npm and n
instructions above.
Updating Node and npm is just the beginning. You’ll want to keep the rest of your packages and dependencies up to date to maximize compatibility and security. Lucky for you, you
now have the newest version of npm — and we’ve written a great how-to guide that walks you through the package update process.
Ask a question and Laura will respond to you. We strive to provide the best advice on the net and we are here to help you in any way we can.
Jone Quest
Hi, nice article! I update node on my ubuntu system and at the end it shows the version v7.4.0 was installed. However when checking the version (node -v ) it shows V4.4.7
Eshwer
sudo ln -sf /usr/local/n/versions/node//bin/node /usr/bin/node
Run this after all the steps then try fro (node -v)
voland62
Why not just maintain the latest stable version in ubuntu official repo?
Fatima
Maldonado
Hi Laura thanks for the tutorial, very useful
cute_girl_20
I want to build ionic app it says update node.js from 4.7.. to version 6 . I am trying to update it to latest version but on running node -v it is still showing 4.7..
sudo npm install -g n
sudo n stable
http://www.hostingadvice.com/how-to/update-node-js-latest-version/
3 Ways to Update Node Versions on Linux-Based Machines
We’re covering all your bases with updating Node on Linux-based operating systems, but Option 1 is by far our most recommended method for simplicity and effectiveness. If extenuatingcircumstances prevent you from going the Node Version Manager route, read on for instructions on updating Node through package managers or binary packages.
1. Update Node Using Node Version Manager
Node Version Manager, or nvm, is far and away the best method to updatingNode. You’ll need a C++ compiler, as well as the build-essential and libssl-dev packages. Run an update first, then get the packages:
1 2 | sudo apt-get update sudo apt-get install build-essential checkinstall libssl-dev |
1 | curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash |
The command will output nvm if everything worked.
Once you’re set up, installing updated versions of Node is a breeze. You can check what versions are currently installed with nvm lsand
see what is available to install by using nvm ls-remote.
Download, compile, and install newer versions of Node with nvm install #.#.#,
obviously substituting the #s for the Node version you want. You can tell nvm which version to use in each new shell with nvm use #.#.# and
set a default with alias: nvm alias default node.
2. Update Node Using a Package Manager
If nvm isn’t for you, a package manager is your next best bet. Node package manager,or npm, helps you discover, share, and use code, along with managing dependencies.
Node comes with npm pre-installed, but the manager is updated more frequently than Node. Run npm -v to
see which version you have, then npm install npm@latest -g to
install the newest npm update. Run npm -v again
if you want to make sure npm updated correctly.
To update Node, you’ll need npm’s handy n module. Run this code to clear
npm’s cache, install n, and install the latest stable version of Node:
1 2 3 | sudo npm cache clean -f sudo npm install -g n sudo n stable |
Alternatively, you can run n #.#.# to
get a specific Node version.
3. Update Node (Ubuntu/Linux/Debian/CentOS) Using Binary Packages
Let’s be honest — you probably don’t want to go this route. If you’re desperate, however, go to the official Node.js downloadspage to get the 32-bit or 64-bit Linux binary file. You can download the file from a browser, but we prefer using the console. Keep in mind, the specific Node version might change as updates are released.
1 | wget https://nodejs.org/dist/v6.9.2/node-v6.9.2-linux-x64.tar.xz |
Next, use this code to install the binary package in usr/local:
1 | tar -C /usr/local --strip-components 1 -xJf node-v6.9.2-linux.x64.tar.xz |
2 a try for the next update.
How to Update Node (Windows/macOS) Using Installers on Nodejs.org
The Node.js downloads page includes binary packages for Windows and macOS— but why make your life more difficult? The pre-made installers — .msi for Windows and .pkg for macOS — make the installation process unbelievably efficient and understandable. Download and run the file, and let the installation wizard take care of the rest.
With each downloaded update, the newer versions of Node and npm will replace the older version.
Alternatively, macOS users can use the npm and n
instructions above.
Your Node Update is Complete! How ‘Bout Your Modules and Packages?
Updating Node and npm is just the beginning. You’ll want to keep the rest of your packages and dependencies up to date to maximize compatibility and security. Lucky for you, younow have the newest version of npm — and we’ve written a great how-to guide that walks you through the package update process.
Questions or Comments? Ask Laura!
Ask a question and Laura will respond to you. We strive to provide the best advice on the net and we are here to help you in any way we can.Jone Quest
Hi, nice article! I update node on my ubuntu system and at the end it shows the version v7.4.0 was installed. However when checking the version (node -v ) it shows V4.4.7
Eshwer
sudo ln -sf /usr/local/n/versions/node//bin/node /usr/bin/node
Run this after all the steps then try fro (node -v)
voland62
Why not just maintain the latest stable version in ubuntu official repo?
Fatima
Maldonado
Hi Laura thanks for the tutorial, very useful
cute_girl_20
I want to build ionic app it says update node.js from 4.7.. to version 6 . I am trying to update it to latest version but on running node -v it is still showing 4.7..
相关文章推荐
- npm, node版本更新
- mac 下更新node.js的版本
- node更新版本
- node更新版本后 sass文件 编译报错
- Mac更新Node.js版本
- node更新版本后sass无法编译解决办法
- node版本更新和npm版本更新
- Node.js实现android的apk版本更新服务器
- Mac下更新node版本
- node和npm版本更新
- node更新版本后sass无法编译解决办法
- 更新npm和node版本
- Windows下更新node版本
- node版本更新后的项目更新
- Linux环境下使用n更新node版本失败的原因与解决
- [node] node 版本更新
- 命令行更新node版本
- 如何更新当前系统的npm和node版本 (on windows)
- node、npm及node_modules中依赖的版本更新