itaylor/redux-socket.io

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

Opened this issue · 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 !

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

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.

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

@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
});

@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 ..

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, 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?

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

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