简体   繁体   English

运行 webpack 时出现“未找到模块”错误

[英]'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.

相关问题 未找到入口模块和 webpack 中的错误 - Error in Entry module not found and in webpack 找不到Webpack模块:错误:无法解析模块 - Webpack Module not found: Error: Cannot resolve module 使用 webpack 找不到模块无服务器 Lambda 错误 - Module not found Serverless Lambda Error with webpack 使用 webpack 时找不到 vertx 模块 - vertx module not found when using webpack 在窗口中运行rspec时出错:找不到Webpack binstubs - Error running rspec in window: Webpack binstubs not found `npx webpack-dev-server` 时 webpack-dev-server 引发“未找到模块:错误:无法解析” - webpack-dev-server raise “Module not found: Error: Can't resolve” when `npx webpack-dev-server` 从CLI命令执行webpack时发生“未找到模块”错误,该命令已在自己库的“/ bin”中注册 - “Module not found” error when execute webpack from the CLI command, registered in “/bin” of own library 使用 ejs 模块运行构建 webpack 时找不到模块 - Module not found when run build webpack with ejs module 运行时出错 next.js - TypeError: (0, react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV) is not a function - Error when running next js - TypeError: (0 , react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV) is not a function 为什么我收到错误 [ERR_MODULE_NOT_FOUND]:运行服务器时找不到模块 - Why I'm getting Error [ERR_MODULE_NOT_FOUND]: Cannot find module when running the server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM