Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference error - Cannot find module 'google-auth-library/build/src/auth/oauth2client' #677

Open
michael-rivera-florencehc-com opened this issue Jan 17, 2024 · 2 comments

Comments

@michael-rivera-florencehc-com
Copy link

michael-rivera-florencehc-com commented Jan 17, 2024

Still have the same issue documented here - #654

When using the following package.json

"dependencies": { "@aws-sdk/client-iam": "^3.414.0", "@aws-sdk/client-sqs": "^3.414.0", "@aws-sdk/client-ssm": "^3.414.0", "@aws-sdk/types": "^3.413.0", "@florencehealthcare/fhc-api": "^2.0.2", "@florencehealthcare/florence-api": "^0.0.10", "axios": "^1.5.0", "csv": "^6.3.3", "dotenv": "^16.3.1", "google-auth-library": "^8.8.0", "google-spreadsheet": "^4.1.0", "json2csv": "^5.0.7", "mongodb": "^6.1.0", "p-map": "^6.0.0" }, "devDependencies": { "@types/google-spreadsheet": "^3.3.2", "@types/lodash": "^4.14.198", "@types/node": "^20.6.3", "@types/p-map": "^2.0.0", "typescript": "^5.2.2" }

Then running tsc, the following error is achieved.

`node_modules/google-spreadsheet/dist/index.d.ts:5:25 - error TS2307: Cannot find module 'google-auth-library/build/src/auth/oauth2client' or its corresponding type declarations.

5 import { Headers } from 'google-auth-library/build/src/auth/oauth2client';


Found 1 error in node_modules/google-spreadsheet/dist/index.d.ts:5`

I have the following tsconfig.json file

{ "compilerOptions": { "lib": ["es2020"], "module": "node16", "esModuleInterop": true, "target": "ES2020", "moduleResolution": "node16", "resolveJsonModule": true, "sourceMap": true, "checkJs": false, "outDir": "dist", "types": ["node"] }, "include": ["./**/*.ts"], "exclude": ["node_modules", "dist"] }

For the file referenced, if I change line 5 from this
import { Headers } from 'google-auth-library/build/src/auth/oauth2client';
to this
import { Headers } from 'google-auth-library/build/src/auth/oauth2client.js';

It works



Updating the latest version did not help. Still the same error. Downgrading to 8.8.0 has the same effect
@theoephraim
Copy link
Owner

ah the joy of dealing with typescript and file paths... This is not really an issue with this module so much as an incompatibility with your build/config setup. Although there are likely ways to make the built code a bit more robust... Particularly migrating this project's build set up to tsup should help as it will spit out a single dist file. But not sure when I will get to that! If I find some time, I may be able to try to recreate this setup and figure out the resolution. I suspect it involves changing moduleResolution setting in your tsconfig?

@oshliaer
Copy link

oshliaer commented Mar 27, 2024

It depends on the compilation settings. Try downgrading the JS version for the build.

Another way - if you sure - just add "skipLibCheck": true to compilerOptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants