0

I am getting the below error after initializing pusher on nextjs application:

export { Client, RegistrationState, TokenProvider };
^^^^^^
SyntaxError: Unexpected token 'export'

I have also tried modifying the next.config.js file to the following:

const withTM = require("next-transpile-modules")(["@pusher/push-notifications-web"])
module.exports = withTM({
  env: {
    apiBaseUrl: "",
    apiBaseUrlChat: ""
  },
});

When I am trying to execute npm run dev, it is giving me the following error:

TypeError: modules.map is not a function
6
  • This looks to have been answered at stackoverflow.com/questions/65936222/…. In short, you may need to: Try to modify the webpack config in next.config.js file to let the babel loader transpile the es6 dependency. You may want to use this package next-transpile-modules Commented Jul 1, 2021 at 14:56
  • Thanks for your response @doydoy, can you share code sample for that? Commented Jul 2, 2021 at 9:36
  • The problem for me was that the lib I used was missing an entry file. What fixed it for me was to add an empty index.js to the package, doing so next-transpile-modules worked and I was able to use the lib. Sounds stupid, but that did the job in my case. Commented Jul 5, 2021 at 8:04
  • Thanks @Tim. But I don't push node_modules file to the server. I can't do that. Commented Jul 5, 2021 at 10:20
  • @hs27 But you could try to manually add an index.js to your client's node_modules to check whether or not this is the issue. Commented Jul 5, 2021 at 10:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.