You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you're looking to manage multiple versions of **`Node.js`** &/or **`npm`**, consider using a [node version manager](https://github.com/search?q=node%20version%20manager&type=repositories)
Copy file name to clipboardexpand all lines: deps/npm/docs/output/configuring-npm/install.html
+3-12
Original file line number
Diff line number
Diff line change
@@ -142,7 +142,7 @@ <h1 id="install">install</h1>
142
142
143
143
<sectionid="table_of_contents">
144
144
<h2id="table-of-contents">Table of contents</h2>
145
-
<divid="_table_of_contents"><ul><li><ahref="#description">Description</a></li><li><ahref="#overview">Overview</a></li><li><ahref="#checking-your-version-of-npm-and-nodejs">Checking your version of npm and Node.js</a></li><li><ahref="#using-a-node-version-manager-to-install-nodejs-and-npm">Using a Node version manager to install Node.js and npm</a></li><ul><li><ahref="#osx-or-linux-node-version-managers">OSX or Linux Node version managers</a></li><li><ahref="#windows-node-version-managers">Windows Node version managers</a></li></ul><li><ahref="#using-a-node-installer-to-install-nodejs-and-npm">Using a Node installer to install Node.js and npm</a></li><ul><li><ahref="#os-x-or-windows-node-installers">OS X or Windows Node installers</a></li><li><ahref="#linux-or-other-operating-systems-node-installers">Linux or other operating systems Node installers</a></li><li><ahref="#less-common-operating-systems">Less-common operating systems</a></li></ul></ul></div>
145
+
<divid="_table_of_contents"><ul><li><ahref="#description">Description</a></li><li><ahref="#overview">Overview</a></li><li><ahref="#checking-your-version-of-npm-and-nodejs">Checking your version of npm and Node.js</a></li><li><ahref="#using-a-node-version-manager-to-install-nodejs-and-npm">Using a Node version manager to install Node.js and npm</a></li><li><ahref="#using-a-node-installer-to-install-nodejs-and-npm">Using a Node installer to install Node.js and npm</a></li><ul><li><ahref="#os-x-or-windows-node-installers">OS X or Windows Node installers</a></li><li><ahref="#linux-or-other-operating-systems-node-installers">Linux or other operating systems Node installers</a></li><li><ahref="#less-common-operating-systems">Less-common operating systems</a></li></ul></ul></div>
Copy file name to clipboardexpand all lines: deps/npm/lib/cli.js
+34-79
Original file line number
Diff line number
Diff line change
@@ -1,41 +1,28 @@
1
-
// This is separate to indicate that it should contain code we expect to work in
2
-
// all conceivably runnable versions of node. This is a best effort to catch
3
-
// syntax errors to give users a good error message if they are using a node
4
-
// version that doesn't allow syntax we are using such as private properties, etc
5
-
constcreateEnginesValidation=()=>{
6
-
constnode=process.version.replace(/-.*$/,'')
1
+
/* eslint-disable max-len */
2
+
// Code in this file should work in all conceivably runnable versions of node.
3
+
// A best effort is made to catch syntax errors to give users a good error message if they are using a node version that doesn't allow syntax we are using in other files such as private properties, etc
4
+
5
+
// Separated out for easier unit testing
6
+
module.exports=asyncprocess=>{
7
+
// set it here so that regardless of what happens later, we don't
8
+
// leak any private CLI configs to other programs
9
+
process.title='npm'
10
+
11
+
// if npm is called as "npmg" or "npm_g", then run in global mode.
`You should probably upgrade to a newer version of node as we can't make any`,
25
-
`promises that npm will work with this version.`,
26
-
`This version of npm supports the following node versions: \`${engines}\`.`,
27
-
'You can find the latest version at https://nodejs.org/.',
28
-
])
29
-
30
-
constbrokenMessage=wrap([
31
-
`ERROR: npm ${npm} is known not to run on Node.js ${node}.`,
32
-
`You'll need to upgrade to a newer Node.js version in order to use this version of npm.`,
33
-
`This version of npm supports the following node versions: \`${engines}\`.`,
34
-
'You can find the latest version at https://nodejs.org/.',
35
-
])
36
-
37
-
// coverage ignored because this is only hit in very unsupported node versions
38
-
// and it's a best effort attempt to show something nice in those cases
19
+
constnpmVersion=`v${pkg.version}`
20
+
21
+
constunsupportedMessage=`npm ${npmVersion} does not support Node.js ${nodeVersion}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`
22
+
23
+
constbrokenMessage=`ERROR: npm ${npmVersion} is known not to run on Node.js ${nodeVersion}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`
24
+
25
+
// Coverage ignored because this is only hit in very unsupported node versions and it's a best effort attempt to show something nice in those cases
// At this point we've required a few files and can be pretty sure
94
-
// we dont contain invalid syntax for this version of node. It's
95
-
// possible a lazy require would, but that's unlikely enough that
96
-
// it's not worth catching anymore and we attach the more important
97
-
// exit handlers.
98
-
validateEngines.off()
53
+
// At this point we've required a few files and can be pretty sure we dont contain invalid syntax for this version of node. It's possible a lazy require would, but that's unlikely enough that it's not worth catching anymore and we attach the more important exit handlers.
// It is now safe to log a warning if they are using a version of node that is not going to fail on syntax errors but is still unsupported and untested and might not work reliably. This is safe to use the logger now which we want since this will show up in the error log too.
0 commit comments