1. Error: Cannot find module ‘webpack/bin/config-yargs’
- 刪除 package.json 中的
webpack-dev-server
- 重新執行
npm i webpack-dev-server
2. TypeError: compilation.mainTemplate.applyPluginsWaterfall is not a function
終端執行
npm i --save-dev html-webpack-plugin@next
3. TypeError: Cannot read property ‘eslint’ of undefined
終端執行
npm install eslint-plugin-html
4. TypeError: Cannot read property ‘vue’ of undefined
終端執行:
npm install vue-loader@latest --save-dev
webpack 配置// webpack.config.js const VueLoaderPlugin = require('vue-loader/lib/plugin') module.exports = { module: { rules: [ // ... other rules { test: /\.vue$/, loader: 'vue-loader' } ] }, plugins: [ // make sure to include the plugin! new VueLoaderPlugin() ] }
5. Invalid CSS after “…load the styles”: expected 1 selector or at-rule
原因: loader 重複
刪除/註釋以下配置// webpack.config.js // { // test: /\.scss$/, // use: [ // 'vue-style-loader', // 'css-loader', // 'sass-loader' // ] // },