El error se ve así:
ERROR Failed to compile with 1 error 下午11:40:17
error in ./src/components/ProductParam.vue?vue&type=script&lang=js&
Module not found: Error: Can't resolve 'process' in 'E:\mooc\vueMallsystem\mimall\src\components'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "process": require.resolve("process/browser") }'
- install 'process'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "process": false }
Comprobado porque las versiones anteriores al paquete web 5 incluían polyfills. El mensaje de error también da este motivo.
Solución:
instalar dependencias
npm install path-browserify
Configuración en vue.config.js
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")
configureWebpack: {
resolve: {
fallback: {
fs: false,
crypto: require.resolve("crypto-browserify")
}
},
plugins: [new NodePolyfillPlugin()],
},