【发布时间】:2020-03-17 02:10:25
【问题描述】:
我有一个基于 Node.js、DynamoDB 和其他 AWS 服务构建的项目,部署在无服务器架构上。我也安装了 ESLint 包。
我收到以下错误:
ESLint: Import and export declarations are not supported yet on Node 8.0.0. (node/no-unsupported-features)
以下是我的项目的详细信息:
Node version: 12.13.0
NPM version: 6.12.0
Serverless version: 1.40.0
ESLint: 6.8.0
我已经通过我的项目的节点版本和我的本地版本进行了双重验证。两者都是相同的(12.13.0)。
我可以使用async/await,但每当我尝试使用import/export时,都会出现错误。
以下是我的 .eslintrc 文件:
{
"extends" : [
"eslint:recommended",
"plugin:node/recommended"
],
"plugins": [
"promise",
"node"
],
"env" : {
"browser" : false,
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"impliedStrict": false
},
"globals" : {
},
"rules": {
"no-console": 0,
"no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": false }],
"node/no-unpublished-require": [
"error",
{
"allowModules": [
"aws-sdk"
]
}
],
"node/no-unsupported-features": ["error", {
"version": 8,
"ignores": []
}]
}
}
`
【问题讨论】:
-
您使用
.js还是.mjs?因为 Node.js 原生支持带有特性标志和新文件扩展名*.mjs的 ES 模块。 -
我正在使用
.js -
您的
.eslintrc.js文件看起来如何? -
@MickaelB 已在问题详情中添加文件内容
标签: node.js npm eslint serverless