Webpack through yarn: stop process and exit code 1 on warning
Running a build process with Webpack, I've got some warnings. I consider some of this warning error, and IMO, it should stop the build process.
> yarn build:staging
yarn run v1.10.1
$ webpack --env.staging --env.NODE_ENV=staging
Version: webpack 4.23.1
[...]
[795] ./src/index.css 1.05 KiB 0 [built]
+ 793 hidden modules
WARNING in ./src/assets/banner/3.jpg
Module build failed (from ./node_modules/image-webpack-loader/index.js):
Error: Command failed: /home/circleci/repo/node_modules/mozjpeg/vendor/cjpeg
/home/circleci/repo/node_modules/mozjpeg/vendor/cjpeg: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
at Promise.all.then.arr (/home/circleci/repo/node_modules/imagemin-mozjpeg/node_modules/execa/index.js:236:11)
at process._tickCallback (internal/process/next_tick.js:68:7)
@ ./src/assets/banner sync ^./.*.jpg$ ./3.jpg
@ ./src/scenes/home/index.js
@ ./src/router.js
@ ./src/index.js
@ multi babel-polyfill ./src/index.js
[...]
Done in 26.03s.
This "warning" should stop the whole process and exit. Is there a way to tell to webpack with yarn as a driver to stop on certain kind of warning (and return an error code)? My CI process considers everything is alright, this is not the behavior I expected.
javascript webpack yarnpkg
|
show 2 more comments
Running a build process with Webpack, I've got some warnings. I consider some of this warning error, and IMO, it should stop the build process.
> yarn build:staging
yarn run v1.10.1
$ webpack --env.staging --env.NODE_ENV=staging
Version: webpack 4.23.1
[...]
[795] ./src/index.css 1.05 KiB 0 [built]
+ 793 hidden modules
WARNING in ./src/assets/banner/3.jpg
Module build failed (from ./node_modules/image-webpack-loader/index.js):
Error: Command failed: /home/circleci/repo/node_modules/mozjpeg/vendor/cjpeg
/home/circleci/repo/node_modules/mozjpeg/vendor/cjpeg: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
at Promise.all.then.arr (/home/circleci/repo/node_modules/imagemin-mozjpeg/node_modules/execa/index.js:236:11)
at process._tickCallback (internal/process/next_tick.js:68:7)
@ ./src/assets/banner sync ^./.*.jpg$ ./3.jpg
@ ./src/scenes/home/index.js
@ ./src/router.js
@ ./src/index.js
@ multi babel-polyfill ./src/index.js
[...]
Done in 26.03s.
This "warning" should stop the whole process and exit. Is there a way to tell to webpack with yarn as a driver to stop on certain kind of warning (and return an error code)? My CI process considers everything is alright, this is not the behavior I expected.
javascript webpack yarnpkg
It's actually an errorerror while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
– t3__rry
Nov 13 '18 at 11:14
I understand the error. I don't want to fix it (my question is not about that). I just want to stop building and return an error code.
– rap-2-h
Nov 13 '18 at 11:17
1
Sorry I didn't understand that. You can set thebail
options to true to exit the process on the first error: webpack.js.org/configuration/other-options/#bail
– t3__rry
Nov 13 '18 at 11:43
@t3__rry Thank you for your answer. Still, bail seems to not fail on warning. Is there a way to fail in warning too? (since the message I got is a warning)
– rap-2-h
Nov 13 '18 at 13:33
1
Thank you! You could post your comments as an answer!
– rap-2-h
Nov 13 '18 at 13:49
|
show 2 more comments
Running a build process with Webpack, I've got some warnings. I consider some of this warning error, and IMO, it should stop the build process.
> yarn build:staging
yarn run v1.10.1
$ webpack --env.staging --env.NODE_ENV=staging
Version: webpack 4.23.1
[...]
[795] ./src/index.css 1.05 KiB 0 [built]
+ 793 hidden modules
WARNING in ./src/assets/banner/3.jpg
Module build failed (from ./node_modules/image-webpack-loader/index.js):
Error: Command failed: /home/circleci/repo/node_modules/mozjpeg/vendor/cjpeg
/home/circleci/repo/node_modules/mozjpeg/vendor/cjpeg: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
at Promise.all.then.arr (/home/circleci/repo/node_modules/imagemin-mozjpeg/node_modules/execa/index.js:236:11)
at process._tickCallback (internal/process/next_tick.js:68:7)
@ ./src/assets/banner sync ^./.*.jpg$ ./3.jpg
@ ./src/scenes/home/index.js
@ ./src/router.js
@ ./src/index.js
@ multi babel-polyfill ./src/index.js
[...]
Done in 26.03s.
This "warning" should stop the whole process and exit. Is there a way to tell to webpack with yarn as a driver to stop on certain kind of warning (and return an error code)? My CI process considers everything is alright, this is not the behavior I expected.
javascript webpack yarnpkg
Running a build process with Webpack, I've got some warnings. I consider some of this warning error, and IMO, it should stop the build process.
> yarn build:staging
yarn run v1.10.1
$ webpack --env.staging --env.NODE_ENV=staging
Version: webpack 4.23.1
[...]
[795] ./src/index.css 1.05 KiB 0 [built]
+ 793 hidden modules
WARNING in ./src/assets/banner/3.jpg
Module build failed (from ./node_modules/image-webpack-loader/index.js):
Error: Command failed: /home/circleci/repo/node_modules/mozjpeg/vendor/cjpeg
/home/circleci/repo/node_modules/mozjpeg/vendor/cjpeg: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
at Promise.all.then.arr (/home/circleci/repo/node_modules/imagemin-mozjpeg/node_modules/execa/index.js:236:11)
at process._tickCallback (internal/process/next_tick.js:68:7)
@ ./src/assets/banner sync ^./.*.jpg$ ./3.jpg
@ ./src/scenes/home/index.js
@ ./src/router.js
@ ./src/index.js
@ multi babel-polyfill ./src/index.js
[...]
Done in 26.03s.
This "warning" should stop the whole process and exit. Is there a way to tell to webpack with yarn as a driver to stop on certain kind of warning (and return an error code)? My CI process considers everything is alright, this is not the behavior I expected.
javascript webpack yarnpkg
javascript webpack yarnpkg
edited Nov 13 '18 at 16:02
tk421
3,50231426
3,50231426
asked Nov 13 '18 at 11:07
rap-2-hrap-2-h
9,745870130
9,745870130
It's actually an errorerror while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
– t3__rry
Nov 13 '18 at 11:14
I understand the error. I don't want to fix it (my question is not about that). I just want to stop building and return an error code.
– rap-2-h
Nov 13 '18 at 11:17
1
Sorry I didn't understand that. You can set thebail
options to true to exit the process on the first error: webpack.js.org/configuration/other-options/#bail
– t3__rry
Nov 13 '18 at 11:43
@t3__rry Thank you for your answer. Still, bail seems to not fail on warning. Is there a way to fail in warning too? (since the message I got is a warning)
– rap-2-h
Nov 13 '18 at 13:33
1
Thank you! You could post your comments as an answer!
– rap-2-h
Nov 13 '18 at 13:49
|
show 2 more comments
It's actually an errorerror while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
– t3__rry
Nov 13 '18 at 11:14
I understand the error. I don't want to fix it (my question is not about that). I just want to stop building and return an error code.
– rap-2-h
Nov 13 '18 at 11:17
1
Sorry I didn't understand that. You can set thebail
options to true to exit the process on the first error: webpack.js.org/configuration/other-options/#bail
– t3__rry
Nov 13 '18 at 11:43
@t3__rry Thank you for your answer. Still, bail seems to not fail on warning. Is there a way to fail in warning too? (since the message I got is a warning)
– rap-2-h
Nov 13 '18 at 13:33
1
Thank you! You could post your comments as an answer!
– rap-2-h
Nov 13 '18 at 13:49
It's actually an error
error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
– t3__rry
Nov 13 '18 at 11:14
It's actually an error
error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
– t3__rry
Nov 13 '18 at 11:14
I understand the error. I don't want to fix it (my question is not about that). I just want to stop building and return an error code.
– rap-2-h
Nov 13 '18 at 11:17
I understand the error. I don't want to fix it (my question is not about that). I just want to stop building and return an error code.
– rap-2-h
Nov 13 '18 at 11:17
1
1
Sorry I didn't understand that. You can set the
bail
options to true to exit the process on the first error: webpack.js.org/configuration/other-options/#bail– t3__rry
Nov 13 '18 at 11:43
Sorry I didn't understand that. You can set the
bail
options to true to exit the process on the first error: webpack.js.org/configuration/other-options/#bail– t3__rry
Nov 13 '18 at 11:43
@t3__rry Thank you for your answer. Still, bail seems to not fail on warning. Is there a way to fail in warning too? (since the message I got is a warning)
– rap-2-h
Nov 13 '18 at 13:33
@t3__rry Thank you for your answer. Still, bail seems to not fail on warning. Is there a way to fail in warning too? (since the message I got is a warning)
– rap-2-h
Nov 13 '18 at 13:33
1
1
Thank you! You could post your comments as an answer!
– rap-2-h
Nov 13 '18 at 13:49
Thank you! You could post your comments as an answer!
– rap-2-h
Nov 13 '18 at 13:49
|
show 2 more comments
1 Answer
1
active
oldest
votes
You could access errors
and warnings
out of a Webpack instance from its stats
object and then choose to reject/exit the process: https://github.com/webpack/docs/wiki/node.js-api
For instance:
if(stats.errors.length > 0 || process.warning.length > 0)
process.exit;
If you want to exit starting at the first error throw you can set the bail
option in your config: https://webpack.js.org/configuration/other-options/#bail
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279671%2fwebpack-through-yarn-stop-process-and-exit-code-1-on-warning%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could access errors
and warnings
out of a Webpack instance from its stats
object and then choose to reject/exit the process: https://github.com/webpack/docs/wiki/node.js-api
For instance:
if(stats.errors.length > 0 || process.warning.length > 0)
process.exit;
If you want to exit starting at the first error throw you can set the bail
option in your config: https://webpack.js.org/configuration/other-options/#bail
add a comment |
You could access errors
and warnings
out of a Webpack instance from its stats
object and then choose to reject/exit the process: https://github.com/webpack/docs/wiki/node.js-api
For instance:
if(stats.errors.length > 0 || process.warning.length > 0)
process.exit;
If you want to exit starting at the first error throw you can set the bail
option in your config: https://webpack.js.org/configuration/other-options/#bail
add a comment |
You could access errors
and warnings
out of a Webpack instance from its stats
object and then choose to reject/exit the process: https://github.com/webpack/docs/wiki/node.js-api
For instance:
if(stats.errors.length > 0 || process.warning.length > 0)
process.exit;
If you want to exit starting at the first error throw you can set the bail
option in your config: https://webpack.js.org/configuration/other-options/#bail
You could access errors
and warnings
out of a Webpack instance from its stats
object and then choose to reject/exit the process: https://github.com/webpack/docs/wiki/node.js-api
For instance:
if(stats.errors.length > 0 || process.warning.length > 0)
process.exit;
If you want to exit starting at the first error throw you can set the bail
option in your config: https://webpack.js.org/configuration/other-options/#bail
answered Nov 13 '18 at 14:33
t3__rryt3__rry
1,82711126
1,82711126
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279671%2fwebpack-through-yarn-stop-process-and-exit-code-1-on-warning%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It's actually an error
error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
– t3__rry
Nov 13 '18 at 11:14
I understand the error. I don't want to fix it (my question is not about that). I just want to stop building and return an error code.
– rap-2-h
Nov 13 '18 at 11:17
1
Sorry I didn't understand that. You can set the
bail
options to true to exit the process on the first error: webpack.js.org/configuration/other-options/#bail– t3__rry
Nov 13 '18 at 11:43
@t3__rry Thank you for your answer. Still, bail seems to not fail on warning. Is there a way to fail in warning too? (since the message I got is a warning)
– rap-2-h
Nov 13 '18 at 13:33
1
Thank you! You could post your comments as an answer!
– rap-2-h
Nov 13 '18 at 13:49