nestjs的角度通用:错误:找不到模块“ ./drivers/node-mongodb-native/connection”

时间:2019-12-15 19:37:20

标签: angular mongodb mongoose nestjs angular-universal

我正在将Angular-universal与nest-js一起使用,它在本地运行良好,但是当我在Heroku上部署它时,出现此错误:

Error: Cannot find module './drivers/node-mongodb-native/connection'.

我不知道是什么原因造成的。 这是我的package.json:

{
  "name": "personal-finance",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "npm run serve:ssr",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "serve": "node serve-script",
    "compile:server": "webpack --config webpack.server.config.js --progress --colors",
    "serve:ssr": "node dist/server",
    "build:ssr": "npm run build:client-and-server-bundles && npm run compile:server",
    "build:client-and-server-bundles": "ng build --prod && ng run personal-finance:server:production",
    "heroku-postbuild": "npm run build:ssr"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~8.2.14",
    "@angular/cdk": "~8.2.3",
    "@angular/common": "~8.2.14",
    "@angular/compiler": "~8.2.14",
    "@angular/core": "~8.2.14",
    "@angular/forms": "~8.2.14",
    "@angular/material": "^8.2.3",
    "@angular/platform-browser": "~8.2.14",
    "@angular/platform-browser-dynamic": "~8.2.14",
    "@angular/platform-server": "~8.2.14",
    "@angular/router": "~8.2.14",
    "@fortawesome/angular-fontawesome": "^0.5.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.26",
    "@fortawesome/free-solid-svg-icons": "^5.12.0",
    "@nestjs/common": "^6.10.11",
    "@nestjs/core": "^6.10.11",
    "@nestjs/jwt": "^6.1.1",
    "@nestjs/mongoose": "^6.1.2",
    "@nestjs/ng-universal": "^2.0.1",
    "@nestjs/passport": "^6.1.1",
    "@nestjs/platform-express": "^6.10.11",
    "@nguniversal/express-engine": "^8.0.0",
    "@nguniversal/module-map-ngfactory-loader": "^8.0.0",
    "@types/node": "~8.9.4",
    "bcrypt": "^3.0.7",
    "cleave.js": "^1.5.3",
    "dotenv": "^8.2.0",
    "hammerjs": "^2.0.8",
    "mongodb": "^3.4.0",
    "mongoose": "^5.8.1",
    "ngx-cleave-directive": "^1.1.3",
    "passport": "^0.4.0",
    "passport-jwt": "^4.0.0",
    "reflect-metadata": "^0.1.13",
    "rxjs": "6.5.3",
    "ts-node": "~7.0.0",
    "tslib": "^1.10.0",
    "typescript": "~3.5.3",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.803.20",
    "@angular/cli": "~8.3.20",
    "@angular/compiler-cli": "~8.2.14",
    "@angular/language-service": "~8.2.14",
    "@types/dotenv": "^8.2.0",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^5.0.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "nodemon": "^1.18.11",
    "protractor": "~5.4.0",
    "rimraf": "^2.6.3",
    "ts-loader": "^5.2.0",
    "tslint": "~5.15.0",
    "wait-on": "^3.2.0",
    "webpack-cli": "^3.1.0"
  },
  "engines": {
    "node": "12.13.1",
    "npm": "6.12.1"
  }
}

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

我临时固定在路径\ node_modules @ nestjs \ ng-universal \ dist \ webpack-config.factory.js中,将mongoose | mongodb添加到

 whitelist: /^(?!(@nestjs\/(common|core|microservices)|livereload|concurrently)).*/

以这种方式

 whitelist: /^(?!(@nestjs\/(common|core|microservices)|livereload|concurrently|mongoose|mongodb)).*/

这篇文章可以帮助https://github.com/nestjs/ng-universal/issues/115#issuecomment-527403032