Javascript mongoose.Types.ObjectId不适用于babel7节点

Javascript mongoose.Types.ObjectId不适用于babel7节点,javascript,node.js,mongoose,babeljs,babel-polyfill,Javascript,Node.js,Mongoose,Babeljs,Babel Polyfill,我使用babel7传输node.js 12代码,遇到了Mongoose代码不再工作的问题。我正在使用mongoose.Types.ObjectId.isValid来验证ObjectId值,在切换到babel7之前,这很好。由于我切换到babel7,我得到了以下代码错误: TypeError:无法读取未定义的属性“ObjectId” 这是我的babel.config.json文件: { "presets": [ ["@babel/preset-env&qu

我使用babel7传输node.js 12代码,遇到了Mongoose代码不再工作的问题。我正在使用mongoose.Types.ObjectId.isValid来验证ObjectId值,在切换到babel7之前,这很好。由于我切换到babel7,我得到了以下代码错误:

TypeError:无法读取未定义的属性“ObjectId”

这是我的babel.config.json文件:

{
  "presets": [
    ["@babel/preset-env"]
  ],
  "plugins": [
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-proposal-object-rest-spread",
    "@babel/plugin-transform-async-to-generator",
    "@babel/plugin-transform-strict-mode",
    "@babel/plugin-transform-destructuring",
    ["@babel/plugin-transform-runtime", {
      "corejs": 3,
      "useESModules": false
    }]
  ]
}
"@babel/cli": "^7.12.1",
    "@babel/core": "^7.12.3",
    "@babel/node": "^7.12.1",
    "@babel/plugin-proposal-class-properties": "^7.12.1",
    "@babel/plugin-proposal-object-rest-spread": "^7.12.1",
    "@babel/plugin-transform-async-to-generator": "^7.12.1",
    "@babel/plugin-transform-destructuring": "^7.12.1",
    "@babel/plugin-transform-modules-commonjs": "^7.10.4",
    "@babel/plugin-transform-runtime": "^7.12.1",
    "@babel/plugin-transform-strict-mode": "^7.12.1",
    "@babel/preset-env": "^7.12.1",
    "@babel/register": "^7.12.1",
    "@babel/runtime-corejs3": "^7.12.5",
我添加了@babel/plugin transform destruction插件,认为这可能是babel transpiling的一个分解问题,但问题仍然存在

我最初使用以下导入语句在代码中访问mongoose:

import mongoose from 'mongoose';
以下是my package.json文件中的babel软件包:

{
  "presets": [
    ["@babel/preset-env"]
  ],
  "plugins": [
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-proposal-object-rest-spread",
    "@babel/plugin-transform-async-to-generator",
    "@babel/plugin-transform-strict-mode",
    "@babel/plugin-transform-destructuring",
    ["@babel/plugin-transform-runtime", {
      "corejs": 3,
      "useESModules": false
    }]
  ]
}
"@babel/cli": "^7.12.1",
    "@babel/core": "^7.12.3",
    "@babel/node": "^7.12.1",
    "@babel/plugin-proposal-class-properties": "^7.12.1",
    "@babel/plugin-proposal-object-rest-spread": "^7.12.1",
    "@babel/plugin-transform-async-to-generator": "^7.12.1",
    "@babel/plugin-transform-destructuring": "^7.12.1",
    "@babel/plugin-transform-modules-commonjs": "^7.10.4",
    "@babel/plugin-transform-runtime": "^7.12.1",
    "@babel/plugin-transform-strict-mode": "^7.12.1",
    "@babel/preset-env": "^7.12.1",
    "@babel/register": "^7.12.1",
    "@babel/runtime-corejs3": "^7.12.5",
下面是我用来启动服务器的start命令:

node dist/bin/www.js
这是我用来传输代码的命令:

node_modules/.bin/babel src -d dist
服务器启动并侦听端口,但在访问ObjectId属性的端点被命中时抛出异常。我不知道这个问题会在哪里