惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - Franky
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
IT之家
IT之家
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
W
WeLiveSecurity
B
Blog RSS Feed
V2EX - 技术
V2EX - 技术
H
Heimdal Security Blog
S
Security @ Cisco Blogs
博客园 - 叶小钗
月光博客
月光博客
Webroot Blog
Webroot Blog
H
Hacker News: Front Page
N
News and Events Feed by Topic
P
Proofpoint News Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Help Net Security
Help Net Security
S
Secure Thoughts
SecWiki News
SecWiki News
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
S
Schneier on Security
A
Arctic Wolf
博客园 - 司徒正美
T
Tor Project blog
T
Tenable Blog
量子位
D
DataBreaches.Net
PCI Perspectives
PCI Perspectives
T
The Exploit Database - CXSecurity.com
T
Threatpost
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
Cloudbric
Cloudbric
T
The Blog of Author Tim Ferriss
N
News | PayPal Newsroom
Project Zero
Project Zero
S
Securelist
Forbes - Security
Forbes - Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
B
Blog
L
LINUX DO - 热门话题
Security Archives - TechRepublic
Security Archives - TechRepublic
O
OpenAI News
C
Cisco Blogs
V
V2EX
P
Privacy & Cybersecurity Law Blog
Cisco Talos Blog
Cisco Talos Blog

Dmitri Pavlutin Blog

Pure Functions in JavaScript: A Beginner's Guide Record Type in TypeScript: A Quick Intro How to Write Comments in React: The Good, the Bad and the Ugly 4 Ways to Create an Enum in JavaScript React forwardRef(): How to Pass Refs to Child Components TypeScript Function Types: A Beginner's Guide How to Use v-model to Access Input Values in Vue Mastering Vue refs: From Zero to Hero Environment Variables in JavaScript: process.env 5 Must-Know Differences Between ref() and reactive() in Vue How to Destructure Props in Vue (Composition API) Triangulation in Test-Driven Development How to Use nextTick() in Vue Programming to Interface Vs to Implementation A Smarter JavaScript Mapper: array.flatMap() Array Grouping in JavaScript: Object.groupBy() How to Access ES Module Metadata using import.meta JSON Modules in JavaScript How to Trim Strings in JavaScript TypeScript Function Overloading How to Debounce and Throttle Callbacks in Vue How to Show/Hide Elements in Vue Sparse vs Dense Arrays in JavaScript How to Fill an Array with Initial Values in JavaScript Covariance and Contravariance in TypeScript What are Higher-Order Functions in JavaScript? How to Use TypeScript with React Components Index Signatures in TypeScript How to Use React useReducer() Hook unknown vs any in TypeScript A Guide to React Context and useContext() Hook How to Use Promise.any() 2 Ways to Remove a Property from an Object in JavaScript 'return await promise' vs 'return promise' in JavaScript How to Use Promise.allSettled() How to Use fetch() with JSON JavaScript Promises: then(f,f) vs then(f).catch(f) What is a Promise in JavaScript? How to Use Promise.all() A Simple Guide to Component Props in React Don't Stop Me Now: How to Use React useTransition() hook A Simple Explanation of JavaScript Variables: const, let, var ES Modules Dynamic Import How to Memoize with React.useMemo() How to Cleanup Async Effects in React Why Math.max() Without Arguments Returns -Infinity How to Debounce and Throttle Callbacks in React Don't Confuse Function Expressions and Function Declarations in JavaScript How to Use ES Modules in Node.js Solving a Mystery Behavior of parseInt() in JavaScript How to Use Array Reduce Method in JavaScript 3 Ways to Merge Arrays in JavaScript A Guide to Jotai: the Minimalist React State Management Library The Difference Between Values and References in JavaScript How to Implement a Queue in JavaScript A Helpful Algorithm to Determine "this" value in JavaScript React useRef() Hook Explained in 3 Steps 7 Interview Questions on "this" keyword in JavaScript. Can You Answer Them? How to Greatly Enhance fetch() with the Decorator Pattern 7 Interview Questions on JavaScript Closures. Can You Answer Them? What's a Method in JavaScript? array.sort() Does Not Simply Sort Numbers in JavaScript How to Solve the Infinite Loop of React.useEffect() The New Array Method You'll Enjoy: array.at(index) What's the Difference between DOM Node and Element? Why Promises Are Faster Than setTimeout()? Everything About Callback Functions in JavaScript How React Updates State 5 Mistakes to Avoid When Using React Hooks 5 Best Practices to Write Quality JavaScript Variables Type checking in JavaScript: typeof and instanceof operators 3 Ways to Check if a Variable is Defined in JavaScript React Forms Tutorial: Access Input Values, Validate, Submit Forms Prototypal Inheritance in JavaScript How to Timeout a fetch() Request How to Learn JavaScript If You're a Beginner A Simple Explanation of React.useEffect() A Simple Explanation of JavaScript Iterators How to Use React Controlled Inputs Everything about null in JavaScript How to Use Fetch with async/await Getting Started with Arrow Functions in JavaScript An Interesting Explanation of async/await in JavaScript Front-end Architecture: Stable and Volatile Dependencies Is it Safe to Compare JavaScript Strings? How to Access Object's Keys, Values, and Entries in JavaScript What Actually is a String in JavaScript? 3 Ways to Shallow Clone Objects in JavaScript (w/ bonuses) Checking if an Array Contains a Value in JavaScript JavaScript Event Delegation: A Beginner's Guide How to Parse URL in JavaScript: hostname, pathname, query, hash 3 Ways to Detect an Array in JavaScript How to Get the Screen, Window, and Web Page Sizes in JavaScript 3 Ways to Check If an Object Has a Property/Key in JavaScript How to Compare Objects in JavaScript Object.is() vs Strict Equality Operator in JavaScript Own and Inherited Properties in JavaScript 5 Differences Between Arrow and Regular Functions How to Use Object Destructuring in JavaScript Your Guide to React.useCallback()
Install Node Like a Boss with nvm
Dmitri Pavlutin · 2015-08-29 · via Dmitri Pavlutin Blog

The problem

Being an active node and npm package manager user, I found the platform amazing, but installing it can be a pain.

Linux (checked in Ubuntu and Mint) offers legacy node version from 0.10.x branch by default. Sometimes this is not useful, especially when you want to use the latest node releases.

The first solution is to install node and npm manually, but this method becomes inconvenient in long term usage. You have download it by hand every time a new version appears and if something goes wrong, then you have to delete it manually too.

The nvm: node version manager

After a quick search of the problem, I landed on the [nvm](https://github.com/creationix/nvm" target="_blank) (Node Version Manager) project. The readme.md is pretty descriptive, allowing to quickly install the manager and make use of it. It's not an AI capable of conquering humanity, but the list of commands is simple and self-explanatory.

Nvm offers the following:

  • Quick nvm installation, with only one wget or curl command
  • Any node version can be installed in one command also
  • Different node versions can be setup and quickly switched
  • Doesn't need God mode (no sudo)

The manager has a small list of cons:

  • It does not support fish
  • Nvm is not available by default in Windows, one more reason why I don't need Windows :)

Generally nvm and node versions installation is very simple. No surprises, no blue screens.

A bit of practice

Now it's keyboard time. Let's install the nvm script and node:

1. Download the nvm
Execute the following command in your terminal:


curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash


Terminal screenshot

or if you're not a fan of curl:


wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash


Terminal screenshot

This will install the script into ~/.nvm folder. To be sure that the nvm command is available, execute:

Now you're ready to rock.

2. Install node
Now having a version available for all your projects is easy. Jump to your home directory:

Type the node installation command:

Terminal screenshot

That's all. Everything will be downloaded and configured by nvm. To make sure it all works smoothly, check the installed node version:

Terminal screenshot

3. Need to install another node version? (skip if you need only one version)
Sometimes is necessary to install different node versions, with the possibility to quickly switch between them. This can be done easily too.
Using an .nvmrc file you can specify what kind of node version you want to install. Type this command to create a new .nvmrc file, indicating to install node from the 0.10 branch:

Now properly install the alternative version:

Terminal screenshot

The script will check the existence of the .nvmrc file in your current directory and install the specified node version. That's all. Now you have installed the 0.10 version, without removing the 0.12. But the active one is still 0.12. To check the existing versions:

Terminal screenshot

And finally to activate the 0.10 version type:

Terminal screenshot

4. Setting the node version for new terminal sessions
Some of the changes made by nvm to node version applies only to current terminal session. If you want to keep the configuration for new sessions, you have the following options: a) Create a .nvmrc file containing the node version in the home or any other root directories; b) Use the command

If you encounter some problems with nvm, try to check the [problems section](https://github.com/creationix/nvm#problems" target="_blank) That's all folks! Enjoy.