npm not start. Error: Cannot find module 'webpack-cli/bin/config-yargs'

1.4k views Asked by At

when I give npm start comand its show internal/modules/cjs/loader.js:883 throw err: Error: Cannot finde module'webpack-cli/bin/config-yargs' plz help me to solve this problem use os : windows 10 node version is v14.16.1

> [email protected] start
> webpack-dev-server

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

Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
- C:\Users\user\Desktop\JS full Course\chapter15.1\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> (C:\Users\user\Desktop\JS full Course\chapter15.1\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: [
    'C:\\Users\\user\\Desktop\\JS full Course\\chapter15.1\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
  ]
}

webpack version 5.37.1 webpack-cli version 4.7.0 webpack-dev-server version 3.11.2

Package.json file is

{
  "name": "chapter15.1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server"
    
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/cli": "^7.14.3",
    "@babel/core": "^7.14.3",
    "@babel/node": "^7.14.2",
    "@babel/polyfill": "^7.12.1",
    "@babel/preset-env": "^7.14.2",
    "@babel/register": "^7.13.16",
    "babel-loader": "^8.2.2",
    "babel-register": "^6.26.0",
    "html-webpack-plugin": "^5.3.1",
    "webpack": "^5.37.1",
    "webpack-cli": "^4.7.0",
    "webpack-dev-server": "^3.11.2"
  }
}
1

There are 1 answers

0
Rukshan Jayasekara On BEST ANSWER
  1. In the Package.json file add a serve script like below and remove the start script. See the documentation.
{
  
  "scripts": {
    "serve": "webpack serve"
    
  },
  1. Then Run this command in your terminal. npm run serve