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.

create-react-app won't build when depending on obj-str

See original GitHub issue

This is a weird one, and I bet this isn’t the right place for it. Running yarn build in my create-react-app project, it fails with:

$ react-scripts build
Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file:

        ./node_modules/obj-str/dist/obj-str.es.js:2 

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

error Command failed with exit code 1.

Following the link, it recommends filing an issue, even though I don’t see why this isn’t working.

My dependencies are:

"axios": "^0.16.2",
"date-fns": "^1.28.5",
"immutability-helper": "^2.4.0",
"lodash": "^4.17.4",
"normalize.css": "^7.0.0",
"obj-str": "^1.0.0",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-redux": "^5.0.6",
"react-scripts": "1.0.14",
"redux": "^3.7.2",
"redux-devtools-extension": "^2.13.2",
"redux-thunk": "^2.2.0",
"reselect": "^3.0.1"

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
lukeedcommented, Oct 3, 2017

Hey there,

Unfortunately, that’s because of this issue.

This module exposes a module entry in the package.json, which webpack will read by default. However, CRA doesn’t respond to this behavior, so the export default function()... statement is making it into your build, which then makes Uglify throw, then prints the message you received.

Closing since this is a heavily discussed CRA issue, but you could manually delete the module field on the node_module/obj-str/package.json file and you should be fine. Annoying, but it works.

FWIW: CRA should be adding a include function that only includes/compiles node_modules if they have a "module" entry. This is what we did in preact-cli for a while.

Hope that helps!

0reactions
lukeedcommented, Aug 27, 2018

@mrchief It should now be fixed 👍 I’m not sure how, but I forgot to publish v1.0.1 after producing fully transformed ES5 code (as seen in dist).

Long overdue now, apologies

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why won't React production build run on the browser?
When I look at your file structure, I see the everything about build is under the build folder. But in your html file,...
Read more >
How To Set Up a React Project with Create React App
Step 1 — Creating a New Project with Create React App. In this step, you'll create a new application using the npm package...
Read more >
Don't use create-react-app: How you can set up your own ...
Difficult to add custom build configs. One way to add custom configs is to eject the app, but then it overrides the Only...
Read more >
Code-Splitting - React
Deciding where in your app to introduce code splitting can be a bit tricky. You want to make sure you choose places that...
Read more >
React Top-Level API
React is the entry point to the React library. If you load React from a <script> tag, these top-level APIs are available on...
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