安装 eslint-plugin-react 时不支持的引擎
Unsupported engine, when installing eslint-plugin-react
这里是 React 新用户,我在安装 eslint-plugin-react
和 eslint-plugin-react-hooks
时在终端中遇到以下错误。
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@es-joy/jsdoccomment@0.10.8',
npm WARN EBADENGINE required: { node: '^12 || ^14 || ^16' },
npm WARN EBADENGINE current: { node: 'v17.3.0', npm: '8.3.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: 'eslint-plugin-jsdoc@36.1.1',
npm WARN EBADENGINE required: { node: '^12 || ^14 || ^16' },
npm WARN EBADENGINE current: { node: 'v17.3.0', npm: '8.3.0' }
npm WARN EBADENGINE }
package.json
{
"name": "postcode-pricing",
"version": "1.0.0",
"description": "Lorum Ipsum",
"main": "index.js",
"scripts": {
"build": "wp-scripts build",
"start": "wp-scripts start",
"start:custom": "wp-scripts start src/index.js --output-path=admin/build",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@wordpress/scripts": "^19.2.2",
"eslint": "^7.32.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0"
}
}
.eslintrc.json
{
"env": {
"browser": true,
"es2021": true
},
"extends": ["plugin:react/recommended", "google"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "react-hooks", "@typescript-eslint"],
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
}
有谁能帮助我理解这些特定错误吗?
此错误意味着这两个包需要 Node 12、14 或 16,但您的 Node 版本是 17。
这只是警告,软件包将像其他软件包一样正确安装。但是可能会出现 Node 版本不匹配导致的错误。最好的办法是暂时使用 Node 16(如果你使用 NVM)。
这里是 React 新用户,我在安装 eslint-plugin-react
和 eslint-plugin-react-hooks
时在终端中遇到以下错误。
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@es-joy/jsdoccomment@0.10.8',
npm WARN EBADENGINE required: { node: '^12 || ^14 || ^16' },
npm WARN EBADENGINE current: { node: 'v17.3.0', npm: '8.3.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: 'eslint-plugin-jsdoc@36.1.1',
npm WARN EBADENGINE required: { node: '^12 || ^14 || ^16' },
npm WARN EBADENGINE current: { node: 'v17.3.0', npm: '8.3.0' }
npm WARN EBADENGINE }
package.json
{
"name": "postcode-pricing",
"version": "1.0.0",
"description": "Lorum Ipsum",
"main": "index.js",
"scripts": {
"build": "wp-scripts build",
"start": "wp-scripts start",
"start:custom": "wp-scripts start src/index.js --output-path=admin/build",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@wordpress/scripts": "^19.2.2",
"eslint": "^7.32.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0"
}
}
.eslintrc.json
{
"env": {
"browser": true,
"es2021": true
},
"extends": ["plugin:react/recommended", "google"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "react-hooks", "@typescript-eslint"],
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
}
有谁能帮助我理解这些特定错误吗?
此错误意味着这两个包需要 Node 12、14 或 16,但您的 Node 版本是 17。
这只是警告,软件包将像其他软件包一样正确安装。但是可能会出现 Node 版本不匹配导致的错误。最好的办法是暂时使用 Node 16(如果你使用 NVM)。