How to solve npm error “npm ERR! code ELIFECYCLE”

juexu

I'm trying to learn webpack following https://www.youtube.com/watch?v=TzdEpgONurw,the video using webpack 4,but I use webpack 5,while I down load webpack-dev-server and npm start,it did not work,I think it is not the issue of version,because I am not totally follow the video,this is my debug log:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 info lifecycle [email protected]~start: [email protected]
7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Walter\Desktop\tut\node_modules\.bin;C:\Python38\Scripts\;C:\Python38\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Users\Walter\AppData\Roaming\ActiveState\bin;C:\Program Files (x86)\ActiveState Komodo IDE 12\;C:\Users\Walter\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Walter\AppData\Roaming\npm
9 verbose lifecycle [email protected]~start: CWD: C:\Users\Walter\Desktop\tut
10 silly lifecycle [email protected]~start: Args: [ '/d /s /c', 'webpack-dev-server --open' ]
11 silly lifecycle [email protected]~start: Returned: code: 1  signal: null
12 info lifecycle [email protected]~start: Failed to exec start script
13 verbose stack Error: [email protected] start: `webpack-dev-server --open`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:314:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:314:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\Users\Walter\Desktop\tut
16 verbose Windows_NT 10.0.18363
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v12.19.0
19 verbose npm  v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] start: `webpack-dev-server --open`
22 error Exit status 1
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Here is my package.json:

{
  "name": "tut",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "webpack",
    "start": "webpack-dev-server --open"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "html-loader": "^1.3.2",
    "html-webpack-plugin": "^4.5.0",
    "webpack": "^5.1.3",
    "webpack-cli": "^4.0.0",
    "webpack-dev-server": "^3.11.0"
  },
  "dependencies": {
    "http-server": "^0.12.3"
  }
}

Here is webpack.config.js

var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
    module: {
      rules: [
        {
          test: /\.html$/i,
          loader: 'html-loader',
          options:{minimize:true}
        },
      ],
    },
    devServer:{
        contentBase:'./dist',
    },
    plugins: [new HtmlWebpackPlugin({
        template:"./src/index.html",
        filename:"./index.html"
    }),
   ]
  };
nishkaush

Try changing your start script in package.json to webpack serve like so:

  "scripts": {
    "build": "webpack",
    "start": "webpack serve"
  }

For enabling HMR, try updating your devServer object in webpack.config.js like so:

devServer: {
   contentBase: './dist',
   hot: true, // <---- add this line
},

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

npm ERR! code ELIFECYCLE npm postinstall script

From Dev

npm run build throws error code ELIFECYCLE

From Dev

Error in protobuf | npm ERR! code ELIFECYCLE :: while setting Sawtooth JavaScript Transaction Processor in Ubuntu 16.04

From Dev

I've this problem when I start npm: npm ERR! code ELIFECYCLE

From Dev

npm error ELIFECYCLE while running the test

From Dev

npm error ELIFECYCLE while running the test

From Dev

npm ERR! Error: spawn ENOENT

From Dev

npm ERR! Error: spawn ENOENT

From Dev

npm ERR! code EMFILE npm ERR! syscall spawn git npm ERR! path git npm ERR! errno EMFILE npm ERR! spawn git EMFILE

From Dev

Getting "npm ERR! code EPEERINVALID" on npm packages global install

From Java

npm ERR! Refusing to delete / code EEXIST

From Dev

npm ERR! fetch failed status code 502

From Dev

Angular NPM Run Prod: Error npm ERR! missing script: prod

From Java

Error: npm ERR! write after end

From Dev

npm ERR! registry error parsing json

From Dev

npm install error code 128

From Dev

npm ERR! not found: git

From Dev

WAR and ERR on npm install

From Dev

npm ERR! not found: git

From Dev

How to solve peerinvalid errors in npm install?

From Dev

How to solve peerinvalid errors in npm install?

From Dev

How to solve npm install but permission deny?

From Java

npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY

From Dev

Strapi + Heroku deployment failed:npm ERR! code ERESOLVE

From Dev

npm ERR! version not found: [email protected] error

From Dev

installing ionic npm ERR! tar.unpack error

From Dev

npm ERR! tar.unpack untar error keep showing

From Java

When I run `npm install`, it returns with `ERR! code EINTEGRITY` (npm 5.3.0)

From Dev

npm ERR! 404 '@reactivex/rxjs' is not in the npm registry

Related Related

  1. 1

    npm ERR! code ELIFECYCLE npm postinstall script

  2. 2

    npm run build throws error code ELIFECYCLE

  3. 3

    Error in protobuf | npm ERR! code ELIFECYCLE :: while setting Sawtooth JavaScript Transaction Processor in Ubuntu 16.04

  4. 4

    I've this problem when I start npm: npm ERR! code ELIFECYCLE

  5. 5

    npm error ELIFECYCLE while running the test

  6. 6

    npm error ELIFECYCLE while running the test

  7. 7

    npm ERR! Error: spawn ENOENT

  8. 8

    npm ERR! Error: spawn ENOENT

  9. 9

    npm ERR! code EMFILE npm ERR! syscall spawn git npm ERR! path git npm ERR! errno EMFILE npm ERR! spawn git EMFILE

  10. 10

    Getting "npm ERR! code EPEERINVALID" on npm packages global install

  11. 11

    npm ERR! Refusing to delete / code EEXIST

  12. 12

    npm ERR! fetch failed status code 502

  13. 13

    Angular NPM Run Prod: Error npm ERR! missing script: prod

  14. 14

    Error: npm ERR! write after end

  15. 15

    npm ERR! registry error parsing json

  16. 16

    npm install error code 128

  17. 17

    npm ERR! not found: git

  18. 18

    WAR and ERR on npm install

  19. 19

    npm ERR! not found: git

  20. 20

    How to solve peerinvalid errors in npm install?

  21. 21

    How to solve peerinvalid errors in npm install?

  22. 22

    How to solve npm install but permission deny?

  23. 23

    npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY

  24. 24

    Strapi + Heroku deployment failed:npm ERR! code ERESOLVE

  25. 25

    npm ERR! version not found: [email protected] error

  26. 26

    installing ionic npm ERR! tar.unpack error

  27. 27

    npm ERR! tar.unpack untar error keep showing

  28. 28

    When I run `npm install`, it returns with `ERR! code EINTEGRITY` (npm 5.3.0)

  29. 29

    npm ERR! 404 '@reactivex/rxjs' is not in the npm registry

HotTag

Archive