itaylor / redux-socket.io

An opinionated connector between socket.io and redux
410 stars 53 forks source link

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

Open mounibec opened 7 years ago

mounibec commented 7 years ago

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:

error

Am I missing something ?

Thanks !

digitaldangal commented 7 years ago

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

itaylor commented 7 years ago

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 commented 7 years ago

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

pensierinmusica commented 7 years ago

@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
});
aboeglin commented 7 years ago

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

aforty commented 7 years ago

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?

itaylor commented 7 years ago

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

aforty commented 7 years ago

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

grapewheel commented 7 years ago

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