【发布时间】:2021-01-08 14:58:17
【问题描述】:
尝试列出 GCP 存储中的存储桶时出现 Module not found: Can't resolve 'fs' 错误。
import { Storage } from '@google-cloud/storage';
const googleCloud = new Storage({
keyFilename: '../../my-project-c1a44bf80be3.json',
projectId: 'my-project',
});
googleCloud.getBuckets().then((x: any) => console.log(x));
my-project-c1a44bf80be3.json(从 GCP 下载)存在且是项目级别
错误:
event - compiled successfully
event - build page: /
wait - compiling...
error - ./node_modules/@google-cloud/storage/build/src/file.js:24:0
Module not found: Can't resolve 'fs'
null
Could not find files for / in .next/build-manifest.json
event - compiled successfully
使用googleapis 时会出现同样的错误。
但是,它不是./node_modules/@google-cloud/storage/build/src/file.js:24:0,而是在googleapis 附带的google-auth-library 模块中。
使用yarn 添加。
【问题讨论】:
标签: node.js npm google-cloud-platform google-cloud-storage google-apis-explorer