googleapis / nodejs-storage

Node.js client for Google Cloud Storage: unified object storage for developers and enterprises, from live data serving to data analytics/ML to data archiving.
https://cloud.google.com/storage/
Apache License 2.0
896 stars 370 forks source link

/@google-cloud/storage/build/cjs/src/file.d.ts:7:30 - error TS2305: Module '"stream"' has no exported member 'PipelineSource' #2348

Closed richardmoore725 closed 11 months ago

richardmoore725 commented 11 months ago

When I try to run /samples/streamFileDownload.js, I meet compile error.

node_modules/@google-cloud/storage/build/cjs/src/file.d.ts:7:30 - error TS2305: Module '"stream"' has no exported member 'PipelineSource'.

7 import { Writable, Readable, PipelineSource } from 'stream';



Found 1 error in node_modules/@google-cloud/storage/build/cjs/src/file.d.ts:7
richardmoore725 commented 11 months ago

Does stream module have PipelineSource type?

ddelgrosso1 commented 11 months ago

@richardmoore725 I assume this is with version 7.4.0? What Node version are you using?

ddelgrosso1 commented 11 months ago

Does adding types:['node'] to your tsconfig resolve the issue?

richardmoore725 commented 11 months ago

node 18.18.0 "@google-cloud/storage": "^7.4.0",

richardmoore725 commented 11 months ago

yes, I have added "compilerOptions": { "target": "es6", "module": "commonjs", "outDir": "dist/", "sourceMap": true, "types":["node"] }

ddelgrosso1 commented 11 months ago

Can you provide me with the full tsconfig and maybe a code snippet or are you running the sample directly?

richardmoore725 commented 11 months ago

I was going to copy a file on my bucket to localhost. await new Storage() .bucket(bucketName) .file(fileName) .createReadStream() .pipe(fs.createWriteStream(destFileName))

richardmoore725 commented 11 months ago

{ "compilerOptions": { "target": "es6", "module": "commonjs", "outDir": "dist/", "sourceMap": true, "types":["node"] }, "files": [ "./node_modules/@types/mocha/index.d.ts", "./node_modules/@types/node/index.d.ts", "./node_modules/@types/express/index.d.ts", "./node_modules/@types/dotenv/index.d.ts", "./node_modules/@types/express-session/index.d.ts", "./src/types/express-validator.d.ts" ], "include": [ "src/*/.ts" ], "exclude": [ "typings/*", "node_modules" ] }

richardmoore725 commented 11 months ago

for package.json :

"scripts": { "build": "npm run tsc", "tsc": "tsc -p tsconfig.json",

richardmoore725 commented 11 months ago

I have tried "yarn build"

ddelgrosso1 commented 11 months ago

Not sure if this is the issue or not but you shouldn't need to add anything under @types to the tsconfig I believe they are included automatically.

ddelgrosso1 commented 11 months ago

I would also check that your @types/node is updated to a recent version.

ddelgrosso1 commented 11 months ago

@richardmoore725 were you able to resolve this issue?

PowerKrautInternet commented 11 months ago

Hi,

I had the same issue. For me i had package: "@types/node": "^14.11.2" Upgraded to the version "@types/node": "^20.9.0" And this resolved the issue for me.

ddelgrosso1 commented 11 months ago

Thanks @PowerKrautInternet for confirming. I'm going to close this issue as it seems updating @types/node resolves this problem.