【发布时间】:2020-07-24 14:43:17
【问题描述】:
我有以下结构。
node_modules
src
- app.js
- newrelic.js
package.json
package-lock.json
在 newrelic.js 中它是一个简单的类
const axios = require('axios')
export default class Newrelic {
static getName() {
return 'Hello;
}
}
在 app.js 中
import Newrelic from "./newrelic";
console.log(Newrelic.getName())
当我运行 node src/app.js 时,我收到了
import Newrelic from "./newrelic";
^^^^^^^
SyntaxError: Cannot use import statement outside a module
我需要什么来完成这项工作?
【问题讨论】:
标签: node.js babeljs package.json