ค้นหาเว็บไซต์

javascript - Webpack ไม่สามารถรวมโปรเจคของฉันได้เมื่อมีการนำเข้า mongodb wrapper


ตอนนี้ฉันกำลังพยายามตั้งค่าโปรเจกต์ด้วย TypeScript และ Webpack ตอนนี้ ฉันต้องการเชื่อมต่อกับฐานข้อมูล MongoDB โดยใช้โมดูล "@stuyk/ezmongodb" ซึ่งเป็นตัวห่อ MongoDB แบบง่าย ปัญหาคือ Webpack ไม่สามารถรวมไฟล์เซิร์ฟเวอร์ของฉันได้เมื่อฉันนำเข้าโมดูลนี้

นี่คือการตั้งค่า webpack ของฉัน:

const webpack = require('webpack')
const path = require('path')
const RemovePlugin = require('remove-files-webpack-plugin')

const buildPath = path.resolve(__dirname, 'build')

const server = {
    entry: './src/server/startup.ts',
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: ['ts-loader', 'eslint-loader'],
                exclude: /node_modules/,
            },
        ],
    },
    plugins: [
        new webpack.DefinePlugin({ 'global.GENTLY': false }),
        new RemovePlugin({
            before: {
                include: [path.resolve(buildPath, 'server')],
            },
            watch: {
                include: [path.resolve(buildPath, 'server')],
            },
        }),
    ],
    optimization: {
        minimize: true,
    },
    resolve: {
        extensions: ['.ts', '.tsx', '.js'],
    },
    output: {
        filename: 'client.[contenthash].js',
        path: path.resolve(buildPath, 'server'),
    },
}

module.exports = [server]

นี่คือไฟล์ tsconfig.json:

{
    "compilerOptions": {
        "typeRoots": ["./node_modules/@types"],
        "types": ["@citizenfx/server"],
        "removeComments": true,
        "noUnusedLocals": false,
        "noUnusedParameters": false,
        "noImplicitReturns": true,
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "allowJs": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "module": "esNext",
        "target": "esNext",
        "rootDir": ".",
        "allowSyntheticDefaultImports": true,
        "declaration": false,
        "esModuleInterop": true
    },
    "include": ["./**/*"],
    "exclude": ["node_modules"]
}

และที่นี่คุณมีไฟล์เริ่มต้น:

console.log('Hello from server!')

import Database from '@stuyk/ezmongodb'

Database.init('asdas', 'fivem', ['users', 'characters'])

และนี่คือสิ่งที่ webpack แสดงในคอนโซล:

assets by status 755 KiB [cached] 1 asset
runtime modules 1.13 KiB 5 modules
modules by path ./node_modules/mongodb/ 784 KiB 99 modules
modules by path ./node_modules/whatwg-url/ 82.4 KiB 13 modules
modules by path ./node_modules/socks/build/ 49.9 KiB 6 modules
modules by path ./node_modules/tr46/ 197 KiB 4 modules
modules by path ./node_modules/@stuyk/ezmongodb/dist/ 30.5 KiB 2 modules
modules by path ./node_modules/saslprep/ 4.81 KiB 2 modules
modules by path ./node_modules/mongodb-connection-string-url/lib/*.js 11.7 KiB 2 modules
modules by path ./node_modules/smart-buffer/build/*.js 47.6 KiB
  ./node_modules/smart-buffer/build/smartbuffer.js 43.5 KiB [built] [code generated]
  ./node_modules/smart-buffer/build/utils.js 4.17 KiB [built] [code generated]
+ 12 modules

WARNING in ./node_modules/bson/dist/bson.browser.esm.js 2175:30-59
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\leono\Desktop\test\node_modules\bson\dist'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
        - install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "crypto": false }
 @ ./node_modules/mongodb/lib/bson.js 5:11-26 17:13-28
 @ ./node_modules/mongodb/lib/index.js 8:15-32 33:13-30
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

WARNING in ./node_modules/mongodb/lib/bson.js 8:11-30
Module not found: Error: Can't resolve 'bson-ext' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib'
 @ ./node_modules/mongodb/lib/index.js 8:15-32 33:13-30
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

WARNING in ./node_modules/mongodb/lib/deps.js 24:4-42
Module not found: Error: Can't resolve 'kerberos' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib'
 @ ./node_modules/mongodb/lib/index.js 98:13-30
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

WARNING in ./node_modules/mongodb/lib/deps.js 29:4-51
Module not found: Error: Can't resolve '@mongodb-js/zstd' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib'
 @ ./node_modules/mongodb/lib/index.js 98:13-30
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

WARNING in ./node_modules/mongodb/lib/deps.js 35:4-38
Module not found: Error: Can't resolve 'snappy' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib'
 @ ./node_modules/mongodb/lib/index.js 98:13-30
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

WARNING in ./node_modules/mongodb/lib/deps.js 37:79-109
Module not found: Error: Can't resolve 'snappy/package.json' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib'
 @ ./node_modules/mongodb/lib/index.js 98:13-30
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

WARNING in ./node_modules/mongodb/lib/deps.js 52:4-34
Module not found: Error: Can't resolve 'aws4' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib'
 @ ./node_modules/mongodb/lib/index.js 98:13-30
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

WARNING in ./node_modules/mongodb/lib/encrypter.js 105:42-97
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/mongodb/lib/connection_string.js 11:20-42
 @ ./node_modules/mongodb/lib/mongo_client.js 6:28-58
 @ ./node_modules/mongodb/lib/index.js 23:23-48 106:21-46
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

WARNING in ./node_modules/mongodb/lib/encrypter.js 108:42-78
Module not found: Error: Can't resolve 'mongodb-client-encryption' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib'
 @ ./node_modules/mongodb/lib/connection_string.js 11:20-42
 @ ./node_modules/mongodb/lib/mongo_client.js 6:28-58
 @ ./node_modules/mongodb/lib/index.js 23:23-48 106:21-46
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

9 warnings have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

ERROR in ./node_modules/ip/lib/ip.js 3:9-22
Module not found: Error: Can't resolve 'os' in 'C:\Users\leono\Desktop\test\node_modules\ip\lib'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
        - install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "os": false }
 @ ./node_modules/socks/build/client/socksclient.js 15:11-24
 @ ./node_modules/socks/build/index.js 13:13-44
 @ ./node_modules/mongodb/lib/cmap/connect.js 5:16-32
 @ ./node_modules/mongodb/lib/sdam/monitor.js 6:18-44
 @ ./node_modules/mongodb/lib/sdam/server.js 13:18-38
 @ ./node_modules/mongodb/lib/sdam/topology.js 16:17-36
 @ ./node_modules/mongodb/lib/operations/connect.js 7:19-46
 @ ./node_modules/mongodb/lib/mongo_client.js 10:18-49
 @ ./node_modules/mongodb/lib/index.js 23:23-48 106:21-46
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/change_stream.js 5:17-34
Module not found: Error: Can't resolve 'timers' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "timers": require.resolve("timers-browserify") }'
        - install 'timers-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "timers": false }
 @ ./node_modules/mongodb/lib/db.js 6:24-50
 @ ./node_modules/mongodb/lib/index.js 17:13-28
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/cmap/auth/gssapi.js 4:12-26
Module not found: Error: Can't resolve 'dns' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib\cmap\auth'
 @ ./node_modules/mongodb/lib/index.js 90:15-44
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/cmap/auth/mongocr.js 4:15-32
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib\cmap\auth'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
        - install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "crypto": false }
 @ ./node_modules/mongodb/lib/cmap/connect.js 13:18-43
 @ ./node_modules/mongodb/lib/sdam/monitor.js 6:18-44
 @ ./node_modules/mongodb/lib/sdam/server.js 13:18-38
 @ ./node_modules/mongodb/lib/sdam/topology.js 16:17-36
 @ ./node_modules/mongodb/lib/operations/connect.js 7:19-46
 @ ./node_modules/mongodb/lib/mongo_client.js 10:18-49
 @ ./node_modules/mongodb/lib/index.js 23:23-48 106:21-46
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/cmap/auth/mongodb_aws.js 4:15-32
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib\cmap\auth'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
        - install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "crypto": false }
 @ ./node_modules/mongodb/lib/cmap/connect.js 14:22-51
 @ ./node_modules/mongodb/lib/sdam/monitor.js 6:18-44
 @ ./node_modules/mongodb/lib/sdam/server.js 13:18-38
 @ ./node_modules/mongodb/lib/sdam/topology.js 16:17-36
 @ ./node_modules/mongodb/lib/operations/connect.js 7:19-46
 @ ./node_modules/mongodb/lib/mongo_client.js 10:18-49
 @ ./node_modules/mongodb/lib/index.js 23:23-48 106:21-46
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/cmap/auth/mongodb_aws.js 5:13-28
Module not found: Error: Can't resolve 'http' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib\cmap\auth'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }
 @ ./node_modules/mongodb/lib/index.js 21:17-36 104:15-34
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/operations/add_user.js 4:15-32
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib\operations'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
        - install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "crypto": false }
 @ ./node_modules/mongodb/lib/admin.js 4:19-51
 @ ./node_modules/mongodb/lib/index.js 6:16-34
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/sdam/monitor.js 4:17-34
Module not found: Error: Can't resolve 'timers' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib\sdam'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "timers": require.resolve("timers-browserify") }'
        - install 'timers-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "timers": false }
 @ ./node_modules/mongodb/lib/sdam/server.js 13:18-38
 @ ./node_modules/mongodb/lib/sdam/topology.js 16:17-36
 @ ./node_modules/mongodb/lib/operations/connect.js 7:19-46
 @ ./node_modules/mongodb/lib/mongo_client.js 10:18-49
 @ ./node_modules/mongodb/lib/index.js 23:23-48 106:21-46
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/sdam/srv_polling.js 4:12-26
Module not found: Error: Can't resolve 'dns' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib\sdam'
 @ ./node_modules/mongodb/lib/index.js 155:20-49
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/sdam/srv_polling.js 5:17-34
Module not found: Error: Can't resolve 'timers' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib\sdam'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "timers": require.resolve("timers-browserify") }'
        - install 'timers-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "timers": false }
 @ ./node_modules/mongodb/lib/index.js 155:20-49
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/sdam/topology.js 5:17-34
Module not found: Error: Can't resolve 'timers' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib\sdam'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "timers": require.resolve("timers-browserify") }'
        - install 'timers-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "timers": false }
 @ ./node_modules/mongodb/lib/operations/connect.js 7:19-46
 @ ./node_modules/mongodb/lib/mongo_client.js 10:18-49
 @ ./node_modules/mongodb/lib/index.js 23:23-48 106:21-46
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/utils.js 5:15-32
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
        - install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "crypto": false }
 @ ./node_modules/mongodb/lib/db.js 27:16-34
 @ ./node_modules/mongodb/lib/index.js 17:13-28
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/utils.js 6:11-24
Module not found: Error: Can't resolve 'os' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
        - install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "os": false }
 @ ./node_modules/mongodb/lib/db.js 27:16-34
 @ ./node_modules/mongodb/lib/index.js 17:13-28
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/utils.js 7:17-34
Module not found: Error: Can't resolve 'timers' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "timers": require.resolve("timers-browserify") }'
        - install 'timers-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "timers": false }
 @ ./node_modules/mongodb/lib/db.js 27:16-34
 @ ./node_modules/mongodb/lib/index.js 17:13-28
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/mongodb/lib/utils.js 8:14-28
Module not found: Error: Can't resolve 'url' in 'C:\Users\leono\Desktop\test\node_modules\mongodb\lib'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }
 @ ./node_modules/mongodb/lib/db.js 27:16-34
 @ ./node_modules/mongodb/lib/index.js 17:13-28
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/saslprep/lib/memory-code-points.js 3:11-24
Module not found: Error: Can't resolve 'fs' in 'C:\Users\leono\Desktop\test\node_modules\saslprep\lib'
 @ ./node_modules/saslprep/index.js 10:4-39
 @ ./node_modules/mongodb/lib/deps.js 46:4-42
 @ ./node_modules/mongodb/lib/index.js 98:13-30
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/saslprep/lib/memory-code-points.js 4:13-28
Module not found: Error: Can't resolve 'path' in 'C:\Users\leono\Desktop\test\node_modules\saslprep\lib'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
        - install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "path": false }
 @ ./node_modules/saslprep/index.js 10:4-39
 @ ./node_modules/mongodb/lib/deps.js 46:4-42
 @ ./node_modules/mongodb/lib/index.js 98:13-30
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/socks/build/client/socksclient.js 14:12-26
Module not found: Error: Can't resolve 'net' in 'C:\Users\leono\Desktop\test\node_modules\socks\build\client'
 @ ./node_modules/socks/build/index.js 13:13-44
 @ ./node_modules/mongodb/lib/cmap/connect.js 5:16-32
 @ ./node_modules/mongodb/lib/sdam/monitor.js 6:18-44
 @ ./node_modules/mongodb/lib/sdam/server.js 13:18-38
 @ ./node_modules/mongodb/lib/sdam/topology.js 16:17-36
 @ ./node_modules/mongodb/lib/operations/connect.js 7:19-46
 @ ./node_modules/mongodb/lib/mongo_client.js 10:18-49
 @ ./node_modules/mongodb/lib/index.js 23:23-48 106:21-46
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

ERROR in ./node_modules/socks/build/common/helpers.js 6:15-32
Module not found: Error: Can't resolve 'stream' in 'C:\Users\leono\Desktop\test\node_modules\socks\build\common'

BREAKING CHANGE: 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.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }
 @ ./node_modules/socks/build/client/socksclient.js 18:18-46
 @ ./node_modules/socks/build/index.js 13:13-44
 @ ./node_modules/mongodb/lib/cmap/connect.js 5:16-32
 @ ./node_modules/mongodb/lib/sdam/monitor.js 6:18-44
 @ ./node_modules/mongodb/lib/sdam/server.js 13:18-38
 @ ./node_modules/mongodb/lib/sdam/topology.js 16:17-36
 @ ./node_modules/mongodb/lib/operations/connect.js 7:19-46
 @ ./node_modules/mongodb/lib/mongo_client.js 10:18-49
 @ ./node_modules/mongodb/lib/index.js 23:23-48 106:21-46
 @ ./node_modules/@stuyk/ezmongodb/dist/index.js 49:16-34
 @ ./src/server/startup.ts 2:0-40 3:0-13

34 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.73.0 compiled with 34 errors and 9 warnings in 7880 ms

asset client.239827fcd22b99e760df.js 33 bytes [emitted] [immutable] [minimized] (name: main)
./src/client/startup.ts 35 bytes [built] [code generated]
webpack 5.73.0 compiled successfully in 2849 ms

ฉันพยายามจะแก้ไขสิ่งนี้มาสองสัปดาห์หรือมากกว่านั้น... ฉันไม่รู้ว่าทำไมมันถึงใช้ไม่ได้ ฉันลองเกือบทุกอย่างแล้ว...

บทความที่เกี่ยวข้อง