0

I have added OneSignal to my NextJS app using yarn add onesignal-node and then imported it in my _app.js file like this import * as OneSignal from 'onesignal-node' but I get

error - ./node_modules/request/lib/har.js:3:0
Module not found: Can't resolve 'fs'

Can someone help. I can't even do a basic import without an error.

Thanks

2
  • 1
    Looks like you're trying to use a Node.js library on client-side code, which won't work as the code will run on the browser. Make sure you only use onesignal-node in server-only code, like getStaticProps/getServerSideProps or API routes. Aug 6, 2021 at 22:29
  • Does this answer your question? Module not found: Can't resolve 'fs' in Next.js application Aug 6, 2021 at 22:32

1 Answer 1

0

Here's a blog post demonstrating how to add push notifications into your NextJS project.

https://onesignal.com/blog/how-to-integrate-onesignal-into-a-next-app/

Keep in mind that what you are doing is not going to work because you are trying to import a Node package that is only for the server-side.

If you want to learn more about our developers' community, take a look at this link https://onesignal.com/onesignal-developers and join us!

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.