question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

npm run build fails to minify

See original GitHub issue

I’m in a situation where a package (base64url), multiple levels deep in my dependency hierarchy, has not compiled their npm code to ES5.

The output looks like

> taiga-app@0.1.0 build /Users/andrewgolightly/work/taiga/events-app
> react-scripts build

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file: 

 	./node_modules/base64url/dist/base64url.js:4 

Read more here: http://bit.ly/2tRViJ9

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! taiga-app@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the taiga-app@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Specifically the dependency chain of packages in my app looks like:

taiga-app@0.1.0 <- uport-connect@0.7.3 <- uport@0.6.2 <- jsontokens@0.7.8 <- base64url@3.0.0

I’ve added an issue to base64url, and no response yet. If I fork the package, and correct it, I’ll need to get all the above packages to update it seems? I don’t really see how I’d just add an updated version to my src directory since my code doesn’t directly depend on the base64url package.

In the docs for create-react-app

In the future, we might start automatically compiling incompatible third-party modules, but it is not currently supported. This approach would also slow down the production builds.

This would actually be super useful in my case here.

Otherwise next steps would be to eject and/or learn how to bundle my app with webpack or gulp?

What’s the best approach here to get this project built so I can deploy it? Thanks.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

6reactions
magician11commented, Jun 30, 2018

Thank you @gaearon

From your suggestions, I got it working by updating the react-scripts version in my package.json file

"react-scripts": "2.0.0-next.3e165448",

then running npm install

npm run build then worked 👍

2reactions
gaearoncommented, Jun 30, 2018

I don’t really see how I’d just add an updated version to my src directory since my code doesn’t directly depend on the base64url package.

You can use Yarn “resolutions” feature to override any nested dependency.

This would actually be super useful in my case here.

You can try 2.x alphas here, but note they’re less stable than 1.x. https://github.com/facebook/create-react-app/issues/3815

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to minify code on npm run build - Stack Overflow
i get an error on minifying the code. I have tried cloning my project and trying to build it, i have tried creating...
Read more >
mkm-module-trainingrecords - npm
Sometimes npm run build works locally but fails during deploy via Heroku. Following are the most common cases. "Module not found: Error: Cannot ......
Read more >
npm run build does not minify bundles #9458 | Support Center
As you can see below, "npm run build" executes correctly with no errors, but the created bundles are identical to the dev versions...
Read more >
Command failed with exit code 1: npm run build - Netlify fix 2020
Udemy Courses:- 9 React Projects on Udemy - https://bit.ly/2D83M8c- 9 React Projects on Gumroad ...
Read more >
npm run build' by webpack, I got an error...help me-Reactjs
How do I resolve the React app error for npm run build "Failed to compile. Failed to minify the bundle."? ... Webpack -...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found