[Solved] Vue package error: Syntax Error: Error: Cannot find module ‘mozjpeg’

Syntax Error: Error: Cannot find module 'mozjpeg'

The main reason is that some dependencies of image webpack loader are not installed successfully, which makes the processing of pictures report errors

Attempting to install dependencies:

npm install mozjpeg

report errors:

mozjpeg pre-build test failed

You can solve this problem by modifying hosts.

Modify hosts for MAC system

Go to this website to download files
open the terminal, enter open/etc
and paste the hosts into the etc folder to replace the original hosts file.

The reinstallation was successful and the packaging was successful.

Read More: