webpack-cli@4 exits with 0 even when failing

Created on 23 Oct 2020  路  14Comments  路  Source: webpack/webpack-cli

Bug report

$ webpack should exit with a non-0 code when it finds an error in webpack.config.js

What is the current behavior?

$ webpack exits with 0 even if it throws a fatal error:

If the current behavior is a bug, please provide the steps to reproduce.

npm install -g webpack webpack-cli@4
echo '.' > webpack.config.js
webpack

Notice that webpack鈥檚 version is irrelevant. webpack-cli is the problem

What is the expected behavior?

webpack-cli@3 worked correctly, it exited with 1.

Other relevant information:
webpack version: 4 or 5 (webpack version irrelevant)
webpack-cli version: 4.1.0
Node.js version: v13.8.0
Operating System: macOS 10.15.4
Additional tools:

All 14 comments

For maintainers only:

  • [ ] webpack-4
  • [ ] webpack-5
  • [ ] bug
  • [ ] critical-bug
  • [ ] enhancement
  • [ ] documentation
  • [ ] performance
  • [ ] dependencies
  • [ ] question

Thanks for the report I'm looking into it.

Working fine for me.

Screenshot at 2020-10-23 07-47-54

I don't know where you're testing because it doesn't work anywhere for me. Here's a plain GitHub Action workflow where CI passes even if webpack fails: https://github.com/fregante/webpack-issue-11789/runs/1296100000?check_suite_focus=true

name: CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps: 
      - run: npm install webpack webpack-cli@4
      - run: echo '.' > webpack.config.js
      - run: npx webpack

Just added a test case for the same in webpack/webpack-cli#1979

The tests in that PR pass while my repro code still shows the issue on both GitHub Actions and my computer.

This means that the test effectively isn鈥檛 testing the same thing/environment.

Here鈥檚 another workflow testing every major version of webpack-cli. Every version correctly fails except v4

https://github.com/fregante/webpack-issue-11789/runs/1297087059?check_suite_focus=true

It's possible that https://github.com/webpack/webpack-cli/pull/1971 fixed it just a couple of days ago but hasn't been pushed yet 馃嵃

can you try with the master branch?

I tried but it's a monorepo, I don't know how to npm install that

You can create a symlink with npm link webpack-cli

@fregante Can you create reproducible test repo, i think fixed in master

@evilebottnawi it's https://github.com/fregante/webpack-issue-11789

The repro is in GitHub Actions, it's only 3 lines:

npm install webpack webpack-cli@4
echo '.' > webpack.config.js
npx webpack

Just ran into this problem. Upgraded to 4.2.0 and verified it worked. Thanks for the fix @snitin315!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

heyalbert picture heyalbert  路  3Comments

RobotnickIsrael picture RobotnickIsrael  路  5Comments

AjayPoshak picture AjayPoshak  路  5Comments

anshumanv picture anshumanv  路  3Comments

logo749 picture logo749  路  4Comments