@google-cloud/storage 在 Angular 14 中安装此软件包后,我遇到了此问题模块“stream”没有导出成员“PipelineSource”

问题描述 投票:0回答:1
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';
                               ~~~~~~~~~~~~~~ 

× Failed to compile.

我已经安装了“@types/node”:“^12.20.55”, 并添加,

"types": ["node"]
tsconfig.json
文件中的编译器选项

typescript google-cloud-storage angular14
1个回答
0
投票

我还在 Angular 12 中使用@google-cloud/storage(最新版本)。但它在构建时本身抛出错误。

./node_modules/@google-cloud/storage/build/cjs/src/transfer-manager.js:103:17-34 - 错误:找不到模块:错误:无法解析“node_modules/@”中的“加密”谷歌云/存储/构建/cjs/src'

重大变更:webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

如果你想包含一个polyfill,你需要: - 添加后备 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }' - 安装“加密浏览器” 如果你不想包含一个polyfill,你可以使用一个空模块,如下所示: solve.fallback: { "crypto": false }

./node_modules/@google-cloud/storage/build/cjs/src/util.js:51:26-41 - 错误:找不到模块:错误:无法解析“/node_modules/@google”中的“路径” -云/存储/构建/cjs/src'

重大变更:webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

如果你想包含一个polyfill,你需要: - 添加后备 'resolve.fallback: { "path": require.resolve("path-browserify") }' - 安装“路径浏览器” 如果你不想包含一个polyfill,你可以使用一个空模块,如下所示: 解析.fallback: { "path": false }

./node_modules/@google-cloud/storage/build/cjs/src/util.js:53:17-34 - 错误:找不到模块:错误:无法解析“/node_modules/@google”中的“流” -云/存储/构建/cjs/src'

重大变更:webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

如果你想包含一个polyfill,你需要: - 添加后备 'resolve.fallback: { "stream": require.resolve("stream-browserify") }' - 安装“流浏览器” 如果你不想包含一个polyfill,你可以使用一个空模块,如下所示: 解析.fallback: { "stream": false }

我也在 webpack 中添加了后备,但它不起作用。同样的错误

resolve: {
    fallback: {
        // "stream": require.resolve("stream-browserify"),
        // "path": require.resolve("path-browserify"),
        // "crypto": require.resolve("crypto-browserify")

        // "stream":'empty',
        // "path": 'empty',
        // "crypto": 'empty'

        "stream": false,
        "path":  false,
        "crypto": false
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.