redux-socket.io icon indicating copy to clipboard operation
redux-socket.io copied to clipboard

Couldn't find preset "es2015" relative to directory node_modules/redux-socket.io

Open mounibec opened this issue 8 years ago • 9 comments

When I add an import createSocketIoMiddleware from 'redux-socket.io'; I get this error in runtime:

Couldn't find preset "es2015" relative to directory node_modules/redux-socket.io

Versions used:

  • "redux-socket.io": "1.4.0",
  • "react": "15.4.2",
  • "react-native": "0.42.0"
error

Am I missing something ?

Thanks !

mounibec avatar Jul 11 '17 12:07 mounibec

I am exact same issue i installed npm install --save-dev babel-preset-es2015 but still not working.anyone find any solution

digitaldangal avatar Jul 12 '17 10:07 digitaldangal

Hmm, I've not seen this myself. Could someone create a minimal reproduction case in a repo so that I can try to figure out what's going on? My guess is that there is some part of the tooling stack you're using that is looking at the .babelrc for this project, which should not be needed/used unless you're building the project from source.

itaylor avatar Jul 12 '17 22:07 itaylor

To test my above theory, you could try removing the file node_modules/redux-socket.io/.babelrc and see if this error goes away.

itaylor avatar Jul 12 '17 22:07 itaylor

@digitaldangal I have exactly the same problem.

It got fixed by running npm i babel-preset-es2015. Although it seems to be a bug of redux-socket.io. @itaylor any idea what could be causing this?

What is this code doing at the beginning of dist/index.js?

Object.defineProperty(exports, "__esModule", {
  value: true
});

pensierinmusica avatar Jul 27 '17 16:07 pensierinmusica

@itaylor No, removing .babelrc doesn't change anything, it's really weird .. I'll go with the solution of @pensierinmusica for now.

edit: Actually the suggested solution doesn't seem to work in my case ..

aboeglin avatar Sep 15 '17 16:09 aboeglin

Removing .babelrc does fix the problem. You have to run watchman watch-del-all && rm -rf $TMPDIR/react-* to clear the build cache.

Can we exclude .babelrc from the package?

aforty avatar Oct 26 '17 19:10 aforty

@aforty, Yes, I think excluding the .babelrc could be done by adding a .npmignore that excludes the .babelrc. That would prevent the .babelrc from being picked up in the npm package. It seems strange that this is necessary, as there should be no reason for your tools to pick it up since the code is shipped pre-compiled by babel. Am I correct in assuming that this only happens to people using react-native?

itaylor avatar Oct 27 '17 04:10 itaylor

Correct, it’s the way the build tool works for react-native unfortunately.

aforty avatar Oct 27 '17 07:10 aforty

npm i babel-preset-es2015 --save-dev OR yarn add babel-preset-es2015 --dev

I'm using the create-react-native-app, it was fixed when installed the preset

grapewheel avatar Nov 04 '17 03:11 grapewheel