[英]'Module not found' error when running webpack
A few days ago to solve a problem with the webpack module, I had to move my global dependencies to Development dependencies, before everything was working correctly, but now when I run the webpack it returns the following error:几天前,为了解决 webpack 模块的问题,我不得不将我的全局依赖项移动到开发依赖项,然后一切正常,但现在当我运行 webpack 时,它返回以下错误:
ERROR in (webpack)/lib/node/NodeTargetPlugin.js
Module not found: Error: Can't resolve 'module' in '.../node_modules/webpack/lib/node'
@ (webpack)/lib/node/NodeTargetPlugin.js 11:1-18
@ ./node_modules/worker-loader/dist/index.js
@ ./node_modules/worker-loader/dist/cjs.js
@ ./node_modules/pdfjs-dist/webpack.js
@ ./src/js/index.js
@ multi ./src/js/index.js
I have already used the methods presented here on StackOverflow and other forums, such as delete the node_modules, yarn.lock folder, clear the cache and as mentioned above install the modules as development dependencies, but nothing worked.我已经在 StackOverflow 和其他论坛上使用过这里介绍的方法,例如删除 node_modules、yarn.lock 文件夹、清除缓存以及如上所述将模块安装为开发依赖项,但没有任何效果。
This is my package.json file这是我的 package.json 文件
{
"name": "AgileTag",
"version": "1.0.0",
"description": "Web app para automatizar a criação de etiquetas",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production",
"start": "webpack-dev-server --mode development --open"
},
"author": "Luis Matheus",
"license": "MIT",
"dependencies": {
"@babel/core": "^7.10.5",
"@babel/polyfill": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@babel/runtime-corejs3": "^7.10.5",
"@babel/types": "^7.10.5",
"babel-core": "^6.26.3",
"babel-loader": "^8.1.0",
"core-js": "^3.6.5",
"live-server": "^1.2.1",
"pdfjs-dist": "^2.4.456",
"regenerator-runtime": "^0.13.5",
"yarn": "^1.22.4"
},
"devDependencies": {
"html-webpack-plugin": "^4.3.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0",
"worker-loader": "^2.0.0"
}
}
I got this same error before and I removed my global webpack, installed locally and run it with web pack, try that我之前遇到过同样的错误,我删除了我的全局 webpack,在本地安装并使用 web 包运行它,试试看
npm remove webpack -g
npm i webpack --save-dev
npm run webpack
If you're running it with local webpack try this: delete packages and install and run.如果您使用本地 webpack 运行它,请尝试以下操作:删除软件包并安装并运行。
npm cache verify
npm install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.