我正在尝试使用 webpack 的 babel-loader 在 JavaScript 中运行异步等待函数。我正在使用以下配置:
{
name: 'client',
context: path.join(__dirname, 'src', 'static', 'scripts'),
entry: {
index: './index.js'
},
output: {
path: path.join(__dirname, 'src', 'static', 'bundles'),
filename: '[name].js'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
query: {
presets: ['es2015', 'stage-0']
}
}
]
},
resolve: {
root: path.join(__dirname),
fallback: path.join(__dirname, 'node_modules'),
modulesDirectories: ['node_modules'],
}
}
Run Code Online (Sandbox Code Playgroud)
但它不断推送错误并显示以下消息:
模块构建失败:错误:./src/static/scripts/index.js:带有选项 {} 的预期类型“标识符”
我的index.js有这样的内容:
console.log('hi from app');
async function hello() {
return Promise.resolve('hi')
}
async function conversation () {
const …Run Code Online (Sandbox Code Playgroud)