Cannot find module “fcm-node” is nodejs ts

  Kiến thức lập trình

I usually use the fcm-node package for sending Firebase push notifications in Node.js. However, this time, I created a TypeScript project and encountered an error.

I am aware that in TypeScript, we need to install type definitions (@types) too. The problem is that when I run npm i @types/fcm-node, it gives me a 404 error. If I’m not mistaken, there are no TypeScript modules available for this package. How can I implement this in TypeScript? Does anyone know of any workarounds? I did try converting my notification.service.ts file to a .js file and used require instead of import in the TypeScript file. This approach worked for npm run dev, but after building with npm run build, when I run dist/index.js, it is unable to find my notification.service.js

LEAVE A COMMENT