0

I have a hard time adding dependencies to a newly generated react-boilerplate project. I face this error:

node.js:122 Uncaught SyntaxError: Unexpected token :
(anonymous function)    @   reactBoilerplateDeps.dll.js:340
__webpack_require__ @   reactBoilerplateDeps.dll.js:21
(anonymous function)    @   application.js:7
...

after adding this dependency to package.json like this:

"feathers-client": "^1.6.1",

and to an existing index.html such as app/containers/App/index.js

import feathers from 'feathers-client';

If I remove the import statement from index.js the error disappears.

I have no clue what is happening so any suggestion will be appreciated.

Some more details:

I started cloning this repository:

https://github.com/mxstbr/react-boilerplate

Then I ran npm run setup. Then I added the dependency to feathers-client and I get the error.

I should also mention that I get similar errors when I add dependencies such as request, feathers-rest and request-promise.

I do not face the error if I add dependencies such as bluebird.

I haven't found a clear pattern into what dependencies gives this error.

Nikola Schou
  • 2,386
  • 3
  • 23
  • 47
  • 1
    Wouldn't `import feathers from 'bluebird'` import the wrong package? Is your webpack config excluding node_modules from being compiled by Babel? – SimpleJ Oct 25 '16 at 22:25
  • The line "import feathers from 'bluebird' " was my mistake. Thx for pointing it out. It did not really fix the problem, just somehow hide it. Sorry for confusing. I have edited my question once again to state the original problem. – Nikola Schou Oct 25 '16 at 22:30
  • You ask: Is your webpack config excluding node_modules from being compiled by Babel? I don't really know. I can't find the webpack config file anywhere. – Nikola Schou Oct 25 '16 at 22:30
  • What boilerplate are you using? – SimpleJ Oct 25 '16 at 23:05
  • I added some more details to the question. – Nikola Schou Oct 26 '16 at 07:30

1 Answers1

1

It looks like the issue is caused by import feathers from "feathers-client" resolving node_modules/feathers-client/lib/client.js instead of the pre-compiled node_modules/feathers-client/dist/feathers.js. To fix this, use:

import feathers from "feathers-client/dist/feathers"
SimpleJ
  • 13,812
  • 13
  • 53
  • 93