firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

Cannot find module '@firebase/logger' or its corresponding type declarations

Open Hyunwoo-o opened this issue 2 years ago • 7 comments

[READ] Step 1: Are you in the right place?

Cloud Firestore support is provided by the @google-cloud/firestore library. Therefore the easiest and most efficient way to get Firestore issues resolved is by directly reporting them at the nodejs-firestore GitHub repo.

If you still think the problem is related to the code in this repository, then read on.

  • For issues or feature requests related to the code in this repository file a Github issue.
  • For general technical questions, post a question on StackOverflow with the firebase tag.
  • For general Firebase discussion, use the firebase-talk google group.
  • For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Operating System version: macOS Ventura 13.1
  • Firebase SDK version: v11.5.0
  • Firebase Product: Firestore
  • Node.js version: v16.19.0
  • NPM version: v8.19.3

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

Execute yarn build in the project firebase-admin SDK has installed.

Relevant Code:

app.listen(app.get('port'), async () => {
  try {
    firebaseAdmin.initializeApp({
      credential: firebaseAdmin.credential.cert({
        projectId: env.FIREBASE.project_id,
        clientEmail: env.FIREBASE.client_email,
        privateKey: env.FIREBASE.private_key,
      }),
    });
    ...
  } catch (err) {
    console.error(err);
  }
});

Error message:

.yarn/cache/@firebase-app-types-npm-0.9.0-c08aff84f3-e79bd3c4a8.zip/node_modules/@firebase/app-types/index.d.ts:17:57 - error TS2307: Cannot find module '@firebase/logger' or its corresponding type declarations.

This issue reproduced after migrating npm to yarn. It was ok with npm build.

Hyunwoo-o avatar Feb 02 '23 12:02 Hyunwoo-o

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Feb 02 '23 12:02 google-oss-bot

Hi @Hyunwoo-o , What does your yarn build script do? Is it trying to build and bundle the app with a tool like webpack? Firebase Admin SDKs are designed to use in privileged server environments and currently it does not work with bundling tools like webpack as it is not common to do so for services running on the backend.

lahirumaramba avatar Feb 03 '23 00:02 lahirumaramba

Hello @lahirumaramba. My yarn build script is very simple: rm -rf ./dist && tsc. I'm just trying to build a simple Node.js express app and deploy to AWS but I got above error on build step.

Hyunwoo-o avatar Feb 03 '23 04:02 Hyunwoo-o

@Hyunwoo-o I believe this is simply a typescript lib check warning. Check your ./dist folder... it is probably compiled successfully. You can have typescript skip that:

// ts-config.json
{
	"compilerOptions": {		
		"skipLibCheck": true
	},
}

keighl avatar Feb 03 '23 18:02 keighl

Are you using yarn pnp? We are looking into an issue with @firebase/database.. dependencies on yarn PNP, Yarn V2, and PNPM. We can't unfortunately promise a timeline on a fix, but if you are using yarn pnp (and the workaround above by @keighl does not work for you), are you able to switch to classic yarn (v1) or npm for now?

lahirumaramba avatar Feb 03 '23 20:02 lahirumaramba

Yes I'm using yarn v2 (yarn berry). I'm using it as a trial, but I didn't know there was such an issue. @keighl 's solution is worked for me. I'll keep it like this as a temporary solution for now.

Hyunwoo-o avatar Feb 07 '23 03:02 Hyunwoo-o

image I am facing same issue while migrating from angular 12 to 13

Shubham161100 avatar Jul 12 '23 11:07 Shubham161100