mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
feat!: add engines.node
field and node.js version check (#1197)
This commit is contained in:
parent
0b634e19a3
commit
d8d10febd5
@ -54,5 +54,8 @@
|
||||
"unbuild": "^0.5.7",
|
||||
"vue-router": "next"
|
||||
},
|
||||
"packageManager": "yarn@3.0.2"
|
||||
"packageManager": "yarn@3.0.2",
|
||||
"engines": {
|
||||
"node": "^14.18.0 || ^16.11.0"
|
||||
}
|
||||
}
|
||||
|
@ -41,5 +41,8 @@
|
||||
"@types/node-fetch": "^3.0.2",
|
||||
"unbuild": "latest",
|
||||
"vue-router": "3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || ^16.11.0"
|
||||
}
|
||||
}
|
||||
|
@ -38,5 +38,8 @@
|
||||
"ufo": "^0.7.9",
|
||||
"unctx": "^1.0.2",
|
||||
"untyped": "^0.2.9"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || ^16.11.0"
|
||||
}
|
||||
}
|
||||
|
@ -77,5 +77,8 @@
|
||||
"@types/node-fetch": "^3.0.2",
|
||||
"@types/serve-static": "^1.13.10",
|
||||
"unbuild": "latest"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || ^16.11.0"
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
"@types/clear": "^0",
|
||||
"@types/mri": "^1.1.1",
|
||||
"@types/rimraf": "^3",
|
||||
"@types/semver": "^7",
|
||||
"chokidar": "^3.5.2",
|
||||
"clear": "^0.1.0",
|
||||
"clipboardy": "^3.0.0",
|
||||
@ -48,5 +49,11 @@
|
||||
"superb": "^4.0.0",
|
||||
"tiged": "^2.12.0",
|
||||
"unbuild": "latest"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || ^16.11.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"semver": "^7.3.5"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import mri from 'mri'
|
||||
import { red, cyan } from 'colorette'
|
||||
import consola from 'consola'
|
||||
import { checkEngines } from './utils/engines'
|
||||
import { commands, Command, NuxtCommand } from './commands'
|
||||
import { showHelp } from './utils/help'
|
||||
import { showBanner } from './utils/banner'
|
||||
@ -22,6 +23,9 @@ async function _main () {
|
||||
command = 'usage'
|
||||
}
|
||||
|
||||
// Check Node.js version in background
|
||||
setTimeout(() => { checkEngines() }, 1000)
|
||||
|
||||
if (command === 'usage') {
|
||||
console.log(`\nUsage: ${cyan(`npx nuxi ${Object.keys(commands).join('|')} [args]`)}\n`)
|
||||
process.exit(1)
|
||||
|
11
packages/nuxi/src/utils/engines.ts
Normal file
11
packages/nuxi/src/utils/engines.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { engines } from '../../package.json'
|
||||
|
||||
export async function checkEngines () {
|
||||
const semver = await import('semver').then(r => r.default || r)
|
||||
const currentNode = process.versions.node
|
||||
const nodeRange = engines.node
|
||||
|
||||
if (!semver.satisfies(process.versions.node, engines.node)) {
|
||||
console.warn(`Current version of Node.js (\`${currentNode}\`) is unsupported and might cause issues.\n Please upgrade to a compatible version (${nodeRange}).`)
|
||||
}
|
||||
}
|
@ -53,5 +53,8 @@
|
||||
"@vue/reactivity": "3.2.20",
|
||||
"@vue/shared": "3.2.20",
|
||||
"vue": "3.2.20"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || ^16.11.0"
|
||||
}
|
||||
}
|
||||
|
@ -33,5 +33,8 @@
|
||||
"ufo": "^0.7.9",
|
||||
"vite": "^2.6.9",
|
||||
"vue": "3.2.20"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || ^16.11.0"
|
||||
}
|
||||
}
|
||||
|
@ -64,5 +64,8 @@
|
||||
"@types/webpack-hot-middleware": "^2.25.5",
|
||||
"@types/webpack-virtual-modules": "^0",
|
||||
"unbuild": "latest"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || ^16.11.0"
|
||||
}
|
||||
}
|
||||
|
@ -13713,6 +13713,7 @@ fsevents@~2.3.2:
|
||||
"@types/clear": ^0
|
||||
"@types/mri": ^1.1.1
|
||||
"@types/rimraf": ^3
|
||||
"@types/semver": ^7
|
||||
chokidar: ^3.5.2
|
||||
clear: ^0.1.0
|
||||
clipboardy: ^3.0.0
|
||||
@ -13731,6 +13732,7 @@ fsevents@~2.3.2:
|
||||
pkg-types: ^0.2.1
|
||||
rimraf: ^3.0.2
|
||||
scule: ^0.2.1
|
||||
semver: ^7.3.5
|
||||
superb: ^4.0.0
|
||||
tiged: ^2.12.0
|
||||
unbuild: latest
|
||||
|
Loading…
Reference in New Issue
Block a user