kentcdodds / advanced-react-patterns-v2

Created with CodeSandbox
https://codesandbox.io/s/github/kentcdodds/advanced-react-patterns-v2
1.51k stars 567 forks source link

npm setup failed to compile #55

Closed suekto-andreas closed 5 years ago

suekto-andreas commented 5 years ago

Replication Steps

  1. git clone the project
  2. run $ npm run setup --silent
  3. Resulted in: Failed to compile Module not found: Error: Can't resolve '@babel/runtime/helpers/esm/inheritsLoose' in '{MY-FOLDER}/github.com/kentcdodds/advanced-react-patterns-v2/node_modules/react-router-dom/esm'

I have checked that there is file under ..node_modules/@babel/runtime/helpers/esm/inheritsLoose.js

Specification

  1. npm version 6.9.0

Kindly help to advise on how to make it successfully compiled, Thanks !

stefansandulescu commented 5 years ago

I have the same problem node v8.14.0 npm v6.4.1

valokin commented 5 years ago

Same problem here only in other js file in node modules, node v8.12.0 npm v6.8.0

kentcdodds commented 5 years ago

Anyone want to figure out what's going on all of a sudden?

valokin commented 5 years ago

Similar issue here https://github.com/gatsbyjs/gatsby/issues/7668 But none of the suggested "fixes" seem to work

valokin commented 5 years ago

I solved the issue for me by just deleting the js file in the node modules that was causing the trouble. More specifically I had this exact same error in "/advanced-react-patterns-v2/node_modules/history/esm/history.js" ( I deleted that very file) and everything seems to be working fine now. Good luck with finding the root of the problem. :) (I'll keep trying myself)

cvqprs commented 5 years ago

Looks like an issue with babel and history package: https://github.com/ReactTraining/history/issues/677

The fast fix will be: vim node_modules/history/esm/history.js

remove the first line: import _extends from '@babel/runtime/helpers/esm/extends'

then run again: npm run setup --silent

suekto-andreas commented 5 years ago

Hi all - I've found a solution without deleting stuff.

In package.json update the react-scripts version.

"react-scripts": "2.1.8",

Does anyone can help to explain / refer me to resources on why this update solve the problem ? I am just curious about the mechanics behind it.

kentcdodds commented 5 years ago

It could be any number of things. The reason it broke probably has to do with a recent release of the history package. Glad that it's working now though.