【发布时间】:2021-10-07 01:30:21
【问题描述】:
app.js
export const temp = "Hello World";
app.test.js
import { temp } from "./app.js";
当我运行 npm test 时,它会抛出 “SyntaxError: Cannot use import statement outside a module”
这是test 脚本:{scripts: {test: "jest"}}
我通过在package.json 中添加"type": "module" 来启用ES 模块。
【问题讨论】:
标签: javascript testing jestjs