我正在为节点制作一个应用程序,该应用程序可以在桌面上执行,而无需安装项目的依赖项,但是我发现我在互联网上找到的文档一直在解决一些问题。
但是存在一个问题,编译Webpack不能解决Firebase依赖关系,并且会给出一些警告,并且在尝试在节点中运行应用程序时会出现错误。 tsconfig.json
{
"compilerOptions": {
"outDir": "./dist",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "commonjs",
"importHelpers": true,
"target": "es2015",
"allowJs": true,
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
],
"resolveJsonModule": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"types": [
"node"
]
},
"include": [
"src/app/**/*.ts"
],
"exclude": [
"node_modules"
]
}
webpack.config.js
const path = require('path');
module.exports = {
mode : 'production',
target : 'node',
entry : './src/app/app.ts',
output : {
filename: 'airtm-dashboard-node.js',
path : path.resolve(__dirname, 'dist'),
},
module : {
rules: [
{
test : /\.tsx?$/,
loader : 'ts-loader',
options: {
transpileOnly: true,
},
exclude: /node_modules/,
},
],
},
plugins: [],
resolve: {
alias : {
// ['firebase/app']: path.resolve(__dirname, 'node_modules/firebase/app/dist/index.cjs.js'),
// ['firebase/firestore']: path.resolve(__dirname, 'node_modules/firebase/firestore/dist/index.cjs.js'),
},
extensions: ['.tsx', '.ts', '.js'],
mainFields: ['main', 'module', 'browser'],
},
};
Firebase.service.ts
import * as firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/firestore';
import { environment } from '../../environments/environment';
firebase.initializeApp(environment.firebaseConfig);
export default firebase;
但是我遇到以下错误。
> webpack
Hash: f5b4800114e68b8e3215
Version: webpack 4.41.0
Time: 1805ms
Built at: 2019-10-01 6:14:44
Asset Size Chunks Chunk Names
airtm-dashboard-node.js 1.03 MiB 0 [emitted] main
Entrypoint main = airtm-dashboard-node.js
[1] external "util" 42 bytes {0} [built]
[2] external "path" 42 bytes {0} [built]
[4] external "fs" 42 bytes {0} [built]
[36] external "url" 42 bytes {0} [built]
[47] ./src/app/services/firebase/firebase.service.ts 400 bytes {0} [built]
[49] external "http" 42 bytes {0} [built]
[50] external "https" 42 bytes {0} [built]
[81] external "child_process" 42 bytes {0} [built]
[142] ./src/app/app.ts 2.59 KiB {0} [built]
[143] ./src/app/services/user/auth.service.ts 1010 bytes {0} [built]
[226] ./src/app/environments/environment.ts 525 bytes {0} [built]
[227] ./src/app/services/user/user-data.service.ts 1.3 KiB {0} [built]
[282] ./src/app/services/user/payments-methods.service.ts 7.24 KiB {0} [built]
[298] external "zlib" 42 bytes {0} [built]
[308] ./src/app/data/airtm-requests/my-payments-methods-data.ts 614 bytes {0} [built]
+ 294 hidden modules
WARNING in ./node_modules/grpc/src/grpc_extension.js 32:12-33
Critical dependency: the request of a dependency is an expression
@ ./node_modules/grpc/index.js
@ ./node_modules/@firebase/firestore/dist/index.node.cjs.js
@ ./node_modules/firebase/firestore/dist/index.cjs.js
@ ./src/app/services/firebase/firebase.service.ts
@ ./src/app/services/user/payments-methods.service.ts
@ ./src/app/app.ts
WARNING in ./node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js 20:22-48
Critical dependency: the request of a dependency is an expression
@ ./node_modules/grpc/src/grpc_extension.js
@ ./node_modules/grpc/index.js
@ ./node_modules/@firebase/firestore/dist/index.node.cjs.js
@ ./node_modules/firebase/firestore/dist/index.cjs.js
@ ./src/app/services/firebase/firebase.service.ts
@ ./src/app/services/user/payments-methods.service.ts
@ ./src/app/app.ts
WARNING in ./node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js 17:20-67
Critical dependency: the request of a dependency is an expression
@ ./node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js
@ ./node_modules/grpc/src/grpc_extension.js
@ ./node_modules/grpc/index.js
@ ./node_modules/@firebase/firestore/dist/index.node.cjs.js
@ ./node_modules/firebase/firestore/dist/index.cjs.js
@ ./src/app/services/firebase/firebase.service.ts
@ ./src/app/services/user/payments-methods.service.ts
@ ./src/app/app.ts
WARNING in ./node_modules/bytebuffer/dist/bytebuffer-node.js
Module not found: Error: Can't resolve 'memcpy' in 'E:\Programación\Proyectos\Node\AirTM-Dashboard-Node\node_modules\bytebuffer\dist'
@ ./node_modules/bytebuffer/dist/bytebuffer-node.js
@ ./node_modules/grpc/node_modules/protobufjs/dist/protobuf.js
@ ./node_modules/grpc/index.js
@ ./node_modules/@firebase/firestore/dist/index.node.cjs.js
@ ./node_modules/firebase/firestore/dist/index.cjs.js
@ ./src/app/services/firebase/firebase.service.ts
@ ./src/app/services/user/payments-methods.service.ts
@ ./src/app/app.ts
我一直在互联网上搜索如何正确配置开发环境,以便能够正确编译要在桌面控制台中执行的应用程序,但是我发现并没有解决问题。
如果您能帮助我解决此问题,我将不胜感激。