Ошибки Webpack с использованием пакета mongodb Node.js - Критическая зависимость: запрос зависимости является выражением - PullRequest
0 голосов
/ 01 ноября 2018

У меня настроен проект Без сервера , и я включил его в свой код:

import { MongoClient } from 'mongodb';

вызывает вывод ниже:

Serverless: Bundling with Webpack...
Time: 1491ms
           Asset     Size  Chunks                    Chunk Names
src/republish.js  1.97 MB       0  [emitted]  [big]  src/republish
   [1] ./node_modules/mongodb-core/index.js 1.76 kB {0} [built]
  [15] ./node_modules/mongodb/lib/cursor.js 36.2 kB {0} [built]
  [24] ./node_modules/mongodb/lib/collection.js 97.5 kB {0} [built]
  [29] ./node_modules/mongodb/lib/db.js 42.8 kB {0} [built]
  [94] ./node_modules/mongodb/lib/admin.js 10.5 kB {0} [built]
  [95] ./node_modules/mongodb/lib/topologies/mongos.js 14.9 kB {0} [built]
  [96] ./node_modules/mongodb/lib/topologies/replset.js 16.1 kB {0} [built]
  [97] ./node_modules/mongodb/lib/gridfs/chunk.js 7.21 kB {0} [built]
 [120] ./src/republish.js 295 bytes {0} [built]
 [121] ./node_modules/mongodb/index.js 2.28 kB {0} [built]
 [150] ./node_modules/mongodb/lib/apm.js 1 kB {0} [built]
 [157] ./node_modules/mongodb/lib/gridfs/grid_store.js 65.9 kB {0} [built]
 [158] ./node_modules/mongodb/lib/gridfs-stream/index.js 11.1 kB {0} [built]
 [161] ./src/get-param.js 365 bytes {0} [built]
 [162] ./node_modules/aws-sdk/clients/ssm.js 541 bytes {0} [built]
    + 225 hidden modules

WARNING in ./node_modules/require_optional/index.js
82:18-42 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/require_optional/index.js
 @ ./node_modules/mongodb-core/index.js
 @ ./node_modules/mongodb/index.js
 @ ./src/republish.js

WARNING in ./node_modules/require_optional/index.js
90:20-44 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/require_optional/index.js
 @ ./node_modules/mongodb-core/index.js
 @ ./node_modules/mongodb/index.js
 @ ./src/republish.js

WARNING in ./node_modules/require_optional/index.js
97:35-67 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/require_optional/index.js
 @ ./node_modules/mongodb-core/index.js
 @ ./node_modules/mongodb/index.js
 @ ./src/republish.js
Serverless: INVOKING INVOKE
Path must be a string. Received undefined

Мой webpack.config.js ниже:

const path = require('path');
// eslint-disable-next-line import/no-unresolved
const slsw = require('serverless-webpack');

module.exports = {
  entry: slsw.lib.entries,
  target: 'node',
  module: {
    loaders: [{
      test: /\.js$/,
      loaders: ['babel-loader'],
      include: __dirname,
      exclude: /node_modules/,
    }],
  },
  output: {
    libraryTarget: 'commonjs',
    path: path.join(__dirname, '.webpack'),
    filename: '[name].js',
  },
};
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...