简体   繁体   English

我遇到了这个错误:当我命令“npm start”时找不到模块“webpack-cli/bin/config-yargs”

[英]I have faced this Error: Cannot find module 'webpack-cli/bin/config-yargs' when I command `npm start`

I have faced problem when I command npm start and it throws errror当我命令npm start时遇到问题,它会抛出错误

$ npm start

> chapter_15_2@1.0.0 start E:\js\stack-learner\chapter_15_2
> webpack-dev-server

internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
- E:\Js\Stack-Learner\chapter_15_2\node_modules\webpack-dev-server\bin\webpack-dev-server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (E:\Js\Stack-Learner\chapter_15_2\node_modules\webpack-dev-server\bin\webpack-dev-server.js:65:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'E:\\Js\\Stack-Learner\\chapter_15_2\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chapter_15_2@1.0.0 start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chapter_15_2@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\neloy\AppData\Roaming\npm-cache\_logs\2021-02-18T06_10_09_676Z-debug.log


code of Package.json . Package.json的代码。

{
  "name": "chapter_15_2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server"
    
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/cli": "^7.12.16",
    "@babel/core": "^7.12.16",
    "@babel/node": "^7.12.16",
    "@babel/polyfill": "^7.12.1",
    "@babel/preset-env": "^7.12.16",
    "@babel/register": "^7.12.13",
    "babel-loader": "^8.2.2",
    "babel-register": "^6.26.0",
    "html-webpack-plugin": "^5.1.0",
    "webpack": "^5.22.0",
    "webpack-cli": "^4.5.0",
    "webpack-dev-server": "^3.11.2"
  }
}


Code of webpack.config.js webpack.config.js代码

const path = require('path')
const htmlWebpackPlugin = require('html-webpack-plugin')
require('babel-register')

module.exports = {
    entry: ['@babel/polyfill', './src/app.js'],
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js'
    },
    module:{
        rules:[
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: ['babel-loader']
            }
        ]
    },
    plugins: [
        new htmlWebpackPlugin({
            template: "./index.html"
        })
    ],
    mode: 'development',
    devtool: 'inline-sourse-map',
    devServer:{
        open: true,
        contentBase: './dist'
    }

}

You need to use npm@6 It's temporary compatibility issue, caused by npm@7 (it was released less then month ago) Just use 6 branch and everything will work for now.您需要使用 npm@6 这是由 npm@7 引起的临时兼容性问题(它是在一个月前发布的)只需使用 6 分支,现在一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行 webpack-dev-server 时找不到模块“webpack-cli/bin/config-yargs” - Cannot find module 'webpack-cli/bin/config-yargs' when running webpack-dev-server 错误:找不到模块“webpack-cli/bin/config-yargs”问题 - Error: Cannot find module 'webpack-cli/bin/config-yargs' problem 如何解决 reactjs 中的“找不到模块 &#39;webpack-cli/bin/config-yargs&#39; 错误? - How to solve 'Cannot find module 'webpack-cli/bin/config-yargs' error in reactjs? 为什么我遇到错误找不到模块 protobufjs - why i faced the Error Cannot find module protobufjs 您已经一起安装了webpack-cli和webpack-command - You have installed webpack-cli and webpack-command together docker 出错(找不到我导出的模块),运行 npm 启动时没有问题 - Error in docker (cannot find module I exported) , not a problem when running npm start 当我运行 npm 启动时,我的 webpack 找不到我的索引。html 页面 - my webpack cannot find my index.html page when I run npm start webpack-cli 无法加载 webpack.config.js 并且找不到 html-webpack-plugin - webpack-cli failed to load webpack.config.js and couldn't find the html-webpack-plugin npx webpack 命令找不到模块 webpack.config.js - npx webpack command cannot find module webpack.config.js 使用npm命令时找不到模块'npmlog'错误消息 - Cannot find module 'npmlog' error message when using npm command
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM