Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add --node-version config to override engine checking

Set to null to disable engine checking altogether, or some semver
string to use that instead of the actual version.
  • Loading branch information...
commit b6828d58414b55bab150ce5e0837de04da94fd59 1 parent e206a4c
@isaacs isaacs authored
View
9 doc/config.md
@@ -360,3 +360,12 @@ default, `npm install foo` will fetch and install the latest version of
Default: true
Show the package description in npm ls.
+
+## node-version
+
+Default: `process.version` from the node environment
+
+An effective version of node to use when checking for "engines"
+compliance.
+
+Set to null or false to suppress engine checking altogether.
View
1  lib/utils/default-config.js
@@ -38,6 +38,7 @@ module.exports =
, loglevel : "info"
, manroot : path.join(process.execPath, "..", "..", "share", "man")
, "must-install" : true
+ , "node-version" : process.version
, outfd : stdio.stdoutFD
, proxy : process.env.http_proxy || null
, prune : undefined // if set to boolean false, then that means "never"
View
2  lib/utils/parse-args.js
@@ -33,6 +33,7 @@ exports.types =
, loglevel : ["silent","win","error","warn","info","verbose","silly"]
, manroot : path
, "must-install" : Boolean
+ , "node-version" : String
, outfd : [Number, Stream]
, proxy : url
, prune : Boolean
@@ -71,6 +72,7 @@ exports.shorthands =
, "no-rb" : ["--no-rebuild-bundle"]
, desc : ["--description"]
, "no-desc" : ["--no-description"]
+ , "nv" : "--node-version"
}
View
10 lib/utils/read-json.js
@@ -218,8 +218,9 @@ function testEngine (json) {
} else json.engines = [ json.engines ]
}
- var nodeVer = process.version.replace(/\+$/, '')
+ var nodeVer = npm.config.get("node-version")
, ok = false
+ if (nodeVer) nodeVer = nodeVer.replace(/\+$/, '')
if (Array.isArray(json.engines)) {
// Packages/1.0 commonjs style, with an array.
// hack it to just hang a "node" member with the version range,
@@ -236,10 +237,13 @@ function testEngine (json) {
if (json.engines.node === "") json.engines.node = "*"
if (json.engines.node && null === semver.validRange(json.engines.node)) {
log.warn( json.engines.node
- , "not a valid range. Please see `npm help json`" )
+ , "Invalid range in engines.node. Please see `npm help json`" )
}
- json._engineSupported = semver.satisfies(nodeVer, json.engines.node||"null")
+ if (nodeVer) {
+ json._engineSupported = semver.satisfies( nodeVer
+ , json.engines.node || "null" )
+ }
if (json.engines.hasOwnProperty("npm") && json._engineSupported) {
json._engineSupported = semver.satisfies(npm.version, json.engines.npm)
}
View
10 man1/config.1
@@ -460,3 +460,13 @@ Default: true
.
.P
Show the package description in npm ls\.
+.
+.SH "node\-version"
+Default: \fBprocess\.version\fR from the node environment
+.
+.P
+An effective version of node to use when checking for "engines"
+compliance\.
+.
+.P
+Set to null or false to suppress engine checking altogether\.
View
10 man1/get.1
@@ -460,3 +460,13 @@ Default: true
.
.P
Show the package description in npm ls\.
+.
+.SH "node\-version"
+Default: \fBprocess\.version\fR from the node environment
+.
+.P
+An effective version of node to use when checking for "engines"
+compliance\.
+.
+.P
+Set to null or false to suppress engine checking altogether\.
View
10 man1/set.1
@@ -460,3 +460,13 @@ Default: true
.
.P
Show the package description in npm ls\.
+.
+.SH "node\-version"
+Default: \fBprocess\.version\fR from the node environment
+.
+.P
+An effective version of node to use when checking for "engines"
+compliance\.
+.
+.P
+Set to null or false to suppress engine checking altogether\.
Please sign in to comment.
Something went wrong with that request. Please try again.