安装后脚本无法部署到MEAN-stack应用程序的Heroku。 (“ build命令需要在Angular项目中运行”)

时间:2019-12-12 21:14:57

标签: node.js angular heroku deployment mean

关于如何将MEAN应用程序部署到Heroku,我已经进行了几次演练。

我的源代码结构:(截屏) https://ibb.co/jy0Th3J

这是我的package.json文件:

    {
  "name": "meanstacknieuw",
  "version": "1.0.0",
  "engines": {
    "node": "10.x",
    "npm": "6.x"
  },
  "description": "refreshing",
  "main": "index.js",
  "scripts": {
    "ng": "ng",
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js",
    "postinstall": "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/vf-app/issues"
  },
  "homepage": "https://github.com/y0u-s/vf-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",
    "jsonwebtoken": "^8.5.1",
    "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"
  }
}

当我想使用git进行部署时,它会给我以下信息:

> ng build --aot --prod

The build command requires to be run in an Angular project, but a project definition could not be found.
  npm ERR! meanstacknieuw@1.0.0 postinstall: `ng build --aot --prod`

这是在我的index.js中:

app.use(express.static(__dirname + '/public'));


app.get('*', function(req, res){
res.sendFile(path.join(__dirname + '/public/index.html'));
    });

什么原因导致此问题?我已经查找了所有相关帖子,但无法解决。 任何帮助,将不胜感激 如果您需要更多背景信息,请告诉我

0 个答案:

没有答案