运行命令npm run start
时,在终端中出现以下错误。
ERROR in multi babel-polyfill ./src/index.js
Module not found: Error: Can't resolve './src/index.js' in '/Users/nezihdogruer/Desktop/jonas2/9-forkify/starter'
@ multi babel-polyfill ./src/index.js app[1]
ERROR in multi (webpack)-dev-server/client?http://localhost:8080 babel-polyfill ./src/index.js
Module not found: Error: Can't resolve './src/index.js' in '/Users/nezihdogruer/Desktop/jonas2/9-forkify/starter'
@ multi (webpack)-dev-server/client?http://localhost:8080 babel-polyfill ./src/index.js app[2]
我正确下载了webpack和babel polyfill,并将babel polyfill保存为包括axios在内的常规依赖项。
由于某种原因,我无法创建.babelrc文件,尽管也许与它有关?
我的webpack配置文件设置如下。
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
app: ['babel-polyfill',
'./src/index.js']
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'js/bundle.js'
},
devServer: {
contentBase: './dist'
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/index.html'
})
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
}
]
}
};
入口点可能有问题吗? 我将不胜感激。 谢谢。