Sage9, yarn run build:production give me error

Hi All,

I’m using Sage9 Beta2, and I want to deploy my theme to server.
I use command: yarn run build:production and below is the output:

yarn run v0.19.1
$ webpack --progress -p --config assets/build/webpack.config.js
 94% asset optimization
Starting to optimize CSS...
Processing styles/main_6064bd9c.css...
Processed styles/main_6064bd9c.css, before: 246089, after: 245454, ratio: 99.74%
Error: dyld: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
  Referenced from: /path/to/code/wp-content/themes/my_theme/node_modules/mozjpeg/vendor/cjpeg
  Reason: image not found

    at Promise.all.then.arr (/path/to/code/wp-content/themes/my_theme/node_modules/execa/index.js:201:11)
    at process._tickCallback (internal/process/next_tick.js:103:7)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Thank you for your help!

You might need to clear your node_modules folder and try to yarn install again?

Thanks @JulienMelissas, I have tried rm -rf node_modules and do yarn install and everything is fine. Then I do yarn run build:production again , but got the same error:

yarn run v0.19.1
$ webpack --progress -p --config assets/build/webpack.config.js
 94% asset optimization
Starting to optimize CSS...
Processing styles/main_6064bd9c.css...
Processed styles/main_6064bd9c.css, before: 246089, after: 245454, ratio: 99.74%
Error: dyld: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
  Referenced from: /path/to/code/wp-content/themes/my_theme/node_modules/mozjpeg/vendor/cjpeg
  Reason: image not found

    at Promise.all.then.arr (/path/to/code/wp-content/themes/my_theme/node_modules/execa/index.js:201:11)
    at process._tickCallback (internal/process/next_tick.js:103:7)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

And you only get this error on build:production? build is fine?

Yes, @JulienMelissas build is fine, no error message.

Hmmm, I’m really not sure what this could be and I can’t reproduce on my end. My production builds work well. Have you ever installed libpng any other way, such as homebrew or something else?

Hi @JulienMelissas, I’m new with macOS, I don’t remember installed libpng, I use docker for my development environment. phpfpm, mysql, nginx, are all in docker

should I install libpng on macOS ?

Thanks,

Thanks @JulienMelissas , after I brew install libpng , the yarn run build:production command run successfully.

2 Likes

Weird that you had to do this, but I’m glad it worked! Since this is the only time this has come up, I’m thinking maybe it was something with your setup.

I am getting a similar error in my production environment. Should I create a new thread?

╰─ (cd theme && yarn build:production)
yarn run v1.3.2
$ webpack --progress -p --config resources/assets/build/webpack.config.js
94% asset optimizationError: Command failed: /var/www/nikkiandrob.info/site/web/app/themes/nikkiandrob-sage/node_modules/mozjpeg/vendor/cjpeg -quality 75
/var/www/nikkiandrob.info/site/web/app/themes/nikkiandrob-sage/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 (/var/www/nikkiandrob.info/site/web/app/themes/nikkiandrob-sage/node_modules/imagemin-mozjpeg/node_modules/execa/index.js:236:11)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This is after doing yarn install --force
I am using linux so I can’t install libpng with brew
Hesitant to apt-get install libpng because it seems to be fixing the symptom not the cause, but I will try it. (What should the real fix be?)

EDIT

Gives the same error after installing libpng-dev

Same error here, using WSL (Ubuntu )

Same error here :frowning:
On Ubuntu.

This 11 month old thread probably isn’t the best place to look for answers. @sinsimon @PJOY