【问题标题】:"You seem to not be depending on "@angular/core" and/or "rxjs". This is an error. " when deploying MEAN-app to Heroku“您似乎不依赖于“@angular/core”和/或“rxjs”。这是一个错误。“将 MEAN-app 部署到 Heroku 时
【发布时间】:2021-01-13 11:08:22
【问题描述】:

我想使用 Heroku 部署我的 MEAN 堆栈应用程序。我关注this tutorial series 主要是为了构建我的应用程序。但是当我通过推送到 GIT 开始部署时,它在构建过程中给了我这个错误:

meanstacknieuw@1.0.0 postinstall /tmp/build_837e48e6_
   > cd client && ng build --aot --prod
   
   You seem to not be depending on "@angular/core" and/or "rxjs". This is an error.
   npm ERR! code ELIFECYCLE
   npm ERR! errno 2
   npm ERR! meanstacknieuw@1.0.0 postinstall: `cd client && ng build --aot --prod`
   npm ERR! Exit status 2
   npm ERR! 
   npm ERR! Failed at the meanstacknieuw@1.0.0 postinstall script.
   npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

这是我的 package.json(服务器端的):

{
  "name": "meanstacknieuw",
  "version": "1.0.0",
  "description": "refreshing",
  "main": "index.js",
  "engines": {
    "node": "10.16.3",
    "npm": "6.11.3"
  },
  "scripts": {
    "ng": "ng",
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js",
    "build": "ng build",
    "heroku-postbuild": "cd client && ng build --aot --prod",
    "postinstall": "cd client && ng build --aot --prod"
  },
   "repository": {
    "type": "git",
    "url": "git+https://github.com/y0u-s/vf-app.git"
  },
  "keywords": [
    "MEAN",
    "stack",
    "angular",
    "2",
   "application"
   ],
  "author": "Youssef",
   "license": "ISC",
   "bugs": {
    "url": "https://github.com/y0u-s/latest-mean-stack-app/issues"
  },
  "homepage": "https://github.com/y0u-s/latest-mean-stack-app#readme",
  "dependencies": {
   "@angular/cli": "^8.3.20",
    "@angular/compiler": "^8.2.14",
    "@angular/compiler-cli": "^8.2.14",
   "angular2-flash-messages": "^3.0.1",
    "bcrypt": "^3.0.4",
    "body-parser": "^1.18.3",
 "cors": "^2.8.5",
"express": "^4.16.4",
"file-extension": "^4.0.5",
"jsonwebtoken": "^8.5.1",
"multer": "^1.4.2",
"node-localstorage": "^2.1.4",
"nodemailer": "^6.4.1",
"simple-odata-server": "^1.1.1",
"typescript": "~3.2.2"
 },
  "devDependencies": {
"@angular-devkit/build-angular": "^0.803.20"
 }
}

怎么了?请让我知道您需要更多上下文。

编辑:

       -----> Restoring cache
      Cached directories were not restored due to a change in version of 
  node, npm, yarn or stack
   Module installation may take longer for this build
   
   -----> Installing dependencies
   Installing node modules
   npm ERR! cipm can only install packages when your package.json and 
package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock 
file with `npm install` before continuing.
   npm ERR! 
   npm ERR! 
   npm ERR! Missing: @angular/rxjs@^8.2.14
   npm ERR! Missing: @angular/core@^8.2.14
   npm ERR! Missing: @angular/common@^8.2.14
   npm ERR! Missing: @angular/platform-browser@^8.2.14
   npm ERR! 
   

【问题讨论】:

    标签: angular heroku deployment mean


    【解决方案1】:

    您是否检查过您的项目目录下是否已有node_modules 目录?如果是这样,请删除目录并重新安装npm install

    我注意到你在package.json 中没有@angular/corerxjs。请通过npm install @angular/core rxjs --save 添加它们。你也应该有@angular/common, @angular/platform-browser

    【讨论】:

    • 我必须在客户端文件夹中安装这些吗?
    • 是的,在package.json所在的目录下。
    • 我的服务器和客户端文件夹中都有 package.json,所以我对此有点困惑
    • 然后在客户端文件夹下进行。
    • 你能看看他的 package.json 文件吗? github.com/gugui3z24/MEAN-Stack-With-Angular-2-Tutorial/blob/…
    【解决方案2】:

    您没有运行 Angular 项目所需的所有依赖项。典型的依赖如下(可能需要不同的版本):

      "dependencies": {
        "@angular/animations": "^10.1.0",
        "@angular/common": "^10.1.0",
        "@angular/compiler": "^10.1.0",
        "@angular/core": "^10.1.0",
        "@angular/forms": "^10.1.0",
        "@angular/platform-browser": "^10.1.0",
        "@angular/platform-browser-dynamic": "^10.1.0",
        "@angular/router": "^10.1.0",
        "@angular/material": "^10.1.2",
        "@angular/cdk": "^10.1.2",
        "typescript": "~3.9.5",
        "rxjs": "~6.5.3",
        "zone.js": "~0.10.3",
        "core-js": "^2.5.4",
        "csstype": "^2.5.8",
        "tslib": "^1.10.0"
      },
    

    【讨论】:

      猜你喜欢
      • 2017-05-22
      • 2018-11-11
      • 2018-07-29
      • 1970-01-01
      • 2019-06-15
      • 2018-09-07
      • 1970-01-01
      • 2022-08-13
      相关资源
      最近更新 更多