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
> [email protected] 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! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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:
[email protected] <- [email protected] <- [email protected] <- [email protected] <- [email protected]
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.
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
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 馃憤
Thanks @magician11 , same worked for me as well after updating react-scripts 馃憤
Thank you @magician11. It's one of those fixes where I would love to know what the problem was. It feels a bit like tarmacing over a molehill!
When you switch to react-scripts 2.0.0, you need to add this to your package.json
"browserslist": [
">0.25%",
"not op_mini all",
"ie 11"
]
@marcoantonioghiani01 I don't think that's relevant to final 2.0.0 though. We decided to always compile down to ES5 for now.
@marcoantonioghiani01 I don't think that's relevant to final 2.0.0 though. We decided to always compile down to ES5 for now.
It was failing to build without it...
Failed to compile.
As of react-scripts >=2 you must specify targeted browsers.
Please add a browserslist key to your package.json.
This sounds like a bug. @Timer we need to update the message?
@marcoantonioghiani01 Can you create a minimal example?
We still require the key because our CSS transforms look for it. You have to explicitly answer no if you don't want the defaults, which will fail the build.
It's expected you add one by hand if you don't like our defaults.
This was excluded from the migration guide because we guide you through it on first run.
We still require the key because our CSS transforms look for it. You have to explicitly answer no if you don't want the defaults, which will fail the build.
It's expected you add one by hand if you don't like our defaults.This was excluded from the migration guide because we guide you through it on first run.
I got the point, that was exactly my behavior.
Would be nice to automatically set your default value and lets the user add/remove options, I think will simplify the procedure. Just in my opinion.
This is behaving as expected. Writing a file change without prompting the user is probably bad.
Most helpful comment
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 installnpm run buildthen worked 馃憤