Compiled with problems: × ERROR in ./node_modules/lop/lib/StringSource.js 1:11-26 Module not found: Error: Can't resolve 'util' in 'D:\project\test111\node_modules\lop\lib' 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: { "util": require.resolve("util/") }' - install 'util' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "util": false } ERROR in ./node_modules/mammoth/lib/docx/docx-reader.js 3:11-26 Module not found: Error: Can't resolve 'path' in 'D:\project\test111\node_modules\mammoth\lib\docx' 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: { "path": require.resolve("path-browserify") }' - install 'path-browserify' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "path": false }
时间: 2024-03-21 17:37:57 浏览: 279
这个错误提示是由 webpack 编译器报出的。从错误信息看,是在编译 lop 和 mammoth 模块时出现了找不到 util 和 path 模块的错误。这是由于 webpack 5 不再默认引入 Node.js 核心模块的 polyfill,需要开发者手动引入或安装相应的 polyfill。
解决方法如下:
1. 安装 polyfill
您可以使用以下命令安装相应的 polyfill 模块:
```
npm install util path-browserify --save-dev
```
2. 配置 webpack
在 webpack 配置文件中添加以下代码:
```
resolve: {
fallback: {
"util": require.resolve("util/"),
"path": require.resolve("path-browserify"),
},
}
```
这样就会在编译时自动引入相应的 polyfill 模块,解决这个错误。
相关问题
in ./node_modules/element-ui/lib/theme-chalk/index.css Syntax Error: TypeError: node.getIterator is not a function ERROR in ./node_modules/element-ui/lib/theme-chalk/index.css (./node_modules/css-loader/dist/cjs.js??clonedRuleSet-14.use[1]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-14.use[2]!./node_modules/element-ui/lib/theme-chalk/index.css) Module build failed (from ./node_modules/css-loader/dist/cjs.js): TypeError: node.getIterator is not a function at LazyResult.visitTick (D:\text\vue-pro\node_modules\postcss\lib\lazy-result.js:530:33) at LazyResult.runAsync (D:\text\vue-pro\node_modules\postcss\lib\lazy-result.js:410:30) at LazyResult.async (D:\text\vue-pro\node_modules\postcss\lib\lazy-result.js:221:30) at LazyResult.then (D:\text\vue-pro\node_modules\postcss\lib\lazy-result.js:206:17) @ ./node_modules/element-ui/lib/theme-chalk/index.css 4:14-156 15:3-20:5 16:22-164 @ ./src/main.js 12:0-46 webpack compiled with 1 error
这个错误可能是由于 postcss-loader 和 css-loader 版本不兼容导致的。你可以尝试升级这两个 loader 的版本,或者降低它们的版本,看看是否解决了这个问题。
另外,你可以尝试在 webpack 配置中添加一个 postcss 配置,指定使用的 postcss 版本,例如:
```js
module.exports = {
// ...
module: {
rules: [
// ...
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
// 指定使用的 postcss 版本
require('postcss')({
// ...
})
]
}
}
}
]
}
]
}
}
```
希望能帮助到你!
WARN "css.modules" option in vue.config.js is deprecated now, please use "css.requireModuleExtension" instead. INFO Starting development server... 98% after emitting CopyPlugin WARNING Compiled with 17 warnings 09:43:57 warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'computed' was not found in 'vue' warning in ./src/router/index.js "export 'default' (imported as 'VueRouter') was not found in 'vue-router' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'defineComponent' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'getCurrentInstance' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'h' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'inject' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'nextTick' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'onActivated' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'onDeactivated' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'onUnmounted' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'provide' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'reactive' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'ref' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'shallowRef' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'unref' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'watch' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'watchEffect' was not found in 'vue'这个报错因为什么
这个报错是因为在使用Vue Router时,导入的Vue Router版本与当前项目中的Vue版本不匹配导致的。具体来说,Vue Router中使用了Vue 3的语法而当前项目中使用的是Vue 2,所以会出现一些语法上的错误。解决方法是将Vue Router更新到与当前项目中使用的Vue版本相匹配的版本。
阅读全文