By Emil Moe
Are there any fixes to npm run prod fails on build? I would like to add this to ensure what is on the live server is always the production build and avoid forgetting doing that before doing a commit.
However, I get this error, which isn’t happening on my local machine, or other servers which are not through “App”:
Browserslist: caniuse-lite is outdated. Please run the following command: `npm update`
ERROR Failed to compile with 1 errors12:32:00 AM
error in ./resources/js/app.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /workspace/node_modules/@babel/helper-compilation-targets/package.json
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
@emilmoe 👋
What does the build command look like that you’re running?
I tried creating the sample-laravel app, updated the build command to be npm run production
, and the output looks successful, but I may not have the exact same app/dependencies as your app:
sample-laravel | 08:43:14 Running custom build command: npm run production
sample-laravel | 08:43:14
sample-laravel | 08:43:14 > @ production /workspace
sample-laravel | 08:43:14 > cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
sample-laravel | 08:43:14
sample-laravel | 08:43:16 Additional dependencies must be installed. This will only take a moment.
sample-laravel | 08:43:16
sample-laravel | 08:43:16 Running: npm install vue-template-compiler --save-dev --production=false
sample-laravel | 08:43:16
sample-laravel | 08:43:25 Okay, done. The following packages have been installed and saved to your package.json dependencies list:
sample-laravel | 08:43:25
sample-laravel | 08:43:25 - vue-template-compiler
sample-laravel | 08:43:25
sample-laravel | 08:43:31 DONE Compiled successfully in 4960ms12:43:31 PM
I see some references to the output you posted in this SO thread and this GH issue, where both mention resolutions of npm update
or upgrading babel dependencies, but it’s not clear if this is relevant to your app/dependencies without more details.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.