我想使用Heroku部署我的MEAN-stack应用程序。我主要关注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! 发布于 2020-09-28 03:35:16
您是否检查了项目目录下是否已经有node_modules目录?如果是,请删除该目录并重新安装npm install。
我注意到你在package.json里没有@angular/core和rxjs。请通过执行npm install @angular/core rxjs --save添加它们。另外,你也应该有@angular/common, @angular/platform-browser。
发布于 2020-09-28 18:59:02
您并不具备运行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"
},https://stackoverflow.com/questions/64092489
复制相似问题