'use strict'
var semver = require('semver')
var supportedNode = [
{ver: '4', min: '4.7.0'},
{ver: '6', min: '6.0.0'},
{ver: '7', min: '7.0.0'},
{ver: '8', min: '8.0.0'},
{ver: '9', min: '9.0.0'}
]
var knownBroken = '<4.7.0'
var checkVersion = exports.checkVersion = function (version) {
var versionNoPrerelease = version.replace(/-.*$/, '')
return {
version: versionNoPrerelease,
broken: semver.satisfies(versionNoPrerelease, knownBroken),
unsupported: !semver.satisfies(versionNoPrerelease, supportedNode.map(function (n) { return '^' + n.min }).join('||'))
}
}
exports.checkForBrokenNode = function () {
var nodejs = checkVersion(process.version)
if (nodejs.broken) {
console.error('ERROR: npm is known not to run on Node.js ' + process.version)
supportedNode.forEach(function (rel) {
if (semver.satisfies(nodejs.version, rel.ver)) {
console.error('Node.js ' + rel.ver + " is supported but the specific version you're running has")
console.error(`a bug known to break npm. Please update to at least ${rel.min} to use this`)
console.error('version of npm. You can find the latest release of Node.js at https://nodejs.org/')
process.exit(1)
}
})
var supportedMajors = supportedNode.map(function (n) { return n.ver }).join(', ')
console.error("You'll need to upgrade to a newer version in order to use this")
console.error('version of npm. Supported versions are ' + supportedMajors + '. You can find the')
console.error('latest version at https://nodejs.org/')
process.exit(1)
}
}
exports.checkForUnsupportedNode = function () {
var nodejs = checkVersion(process.version)
if (nodejs.unsupported) {
var log = require('npmlog')
var supportedMajors = supportedNode.map(function (n) { return n.ver }).join(', ')
log.warn('npm', 'npm does not support Node.js ' + process.version)
log.warn('npm', 'You should probably upgrade to a newer version of node as we')
log.warn('npm', "can't make any promises that npm will work with this version.")
log.warn('npm', 'Supported releases of Node.js are the latest release of ' + supportedMajors + '.')
log.warn('npm', 'You can find the latest version at https://nodejs.org/')
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| completion | Folder | 0755 |
|
|
| ansi-trim.js | File | 211 B | 0644 |
|
| child-path.js | File | 290 B | 0644 |
|
| completion.sh | File | 1.74 KB | 0755 |
|
| correct-mkdir.js | File | 3.04 KB | 0644 |
|
| deep-sort-object.js | File | 363 B | 0644 |
|
| depr-check.js | File | 451 B | 0644 |
|
| did-you-mean.js | File | 495 B | 0644 |
|
| error-handler.js | File | 6.05 KB | 0644 |
|
| error-message.js | File | 10.21 KB | 0644 |
|
| escape-arg.js | File | 673 B | 0644 |
|
| escape-exec-path.js | File | 777 B | 0644 |
|
| gently-rm.js | File | 484 B | 0644 |
|
| get-publish-config.js | File | 919 B | 0644 |
|
| git.js | File | 1.26 KB | 0644 |
|
| gunzip-maybe.js | File | 552 B | 0644 |
|
| is-registry.js | File | 294 B | 0644 |
|
| is-windows-bash.js | File | 129 B | 0644 |
|
| is-windows-shell.js | File | 153 B | 0644 |
|
| is-windows.js | File | 59 B | 0644 |
|
| lifecycle-cmd.js | File | 496 B | 0644 |
|
| lifecycle.js | File | 364 B | 0644 |
|
| link.js | File | 234 B | 0644 |
|
| locker.js | File | 1.81 KB | 0644 |
|
| map-to-registry.js | File | 2.79 KB | 0644 |
|
| metrics-launch.js | File | 1.05 KB | 0644 |
|
| metrics.js | File | 2.03 KB | 0644 |
|
| module-name.js | File | 935 B | 0644 |
|
| move.js | File | 290 B | 0644 |
|
| no-progress-while-running.js | File | 541 B | 0644 |
|
| output.js | File | 210 B | 0644 |
|
| package-id.js | File | 399 B | 0644 |
|
| parse-json.js | File | 592 B | 0644 |
|
| perf.js | File | 562 B | 0644 |
|
| pick-manifest-from-registry-metadata.js | File | 905 B | 0644 |
|
| pulse-till-done.js | File | 783 B | 0644 |
|
| read-local-package.js | File | 329 B | 0644 |
|
| read-user-info.js | File | 1.75 KB | 0644 |
|
| save-stack.js | File | 349 B | 0644 |
|
| spawn.js | File | 1.38 KB | 0644 |
|
| temp-filename.js | File | 173 B | 0644 |
|
| umask.js | File | 343 B | 0644 |
|
| unix-format-path.js | File | 85 B | 0644 |
|
| unsupported.js | File | 2.21 KB | 0644 |
|
| usage.js | File | 576 B | 0644 |
|
| warn-deprecated.js | File | 556 B | 0644 |
|