在 Angular 5 中创建构建时出错
Posted
技术标签:
【中文标题】在 Angular 5 中创建构建时出错【英文标题】:getting error while creating build in angular 5 【发布时间】:2019-09-30 09:07:51 【问题描述】:我正在尝试创建构建并遇到错误
11 愚蠢的生命周期企业解决方案@0.0.0~start:返回:代码:139 信号:null
11 愚蠢的生命周期企业解决方案@0.0.0~start:返回:代码:139 信号:null
12 info生命周期corporate-solutions@0.0.0~start: 执行启动脚本失败
13 详细堆栈退出状态 139
EventEmitter 的 13 个详细堆栈。 (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
emitTwo (events.js:126:13) 的 13 个详细堆栈
EventEmitter.emit (events.js:214:7) 的 13 个详细堆栈
ChildProcess 的 13 个详细堆栈。 (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
emitTwo (events.js:126:13) 的 13 个详细堆栈
ChildProcess.emit (events.js:214:7) 的 13 个详细堆栈
mayberClose 的 13 个详细堆栈 (internal/child_process.js:925:16)
Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) 处的 13 个详细堆栈
启动服务器时有时也会出现同样的错误
-
npm 版本 v5.7.1
节点版本 v8.9.3
操作系统:ubuntu 16.04 LTS
下面是我的 package.json
"name": "corporate-solutions",
"version": "0.0.0",
"scripts":
"ng": "ng",
"start": "ng serve --ec true --port 4203 --host 0.0.0.0",
"build": "node --max_old_space_size=5300 ./node_modules/.bin/ng build --prod",
"win-build": "node --max_old_space_size=5300 ./node_modules/@angular/cli/bin/ng build --prod",
"build-notify": "node --max_old_space_size=5300 ./node_modules/.bin/ng build --prod && echo 'message: Build Completed' | zenity --notification --listen",
"build-push": "node --max_old_space_size=5300 ./node_modules/.bin/ng build --prod && ./distupload.sh",
"gitbuild": "ng build --prod --base /start-angular/SB-Admin-BS4-Angular-4/master/dist/",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"start:dynamic": "npm run build:dynamic && npm run serve:dynamic",
"start:static": "npm run build:static && npm run serve:static",
"build:client-and-server-bundles": "ng build --prod && ng build --prod --app 1 --output-hashing=false",
"build:static": "npm run build:client-and-server-bundles && npm run webpack:server && npm run generate:static",
"build:dynamic": "npm run build:client-and-server-bundles && npm run webpack:server",
"generate:static": "cd dist && node prerender",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors",
"serve:static": "cd dist/browser && http-server",
"serve:dynamic": "node dist/server"
,
"private": true,
"dependencies":
"@angular/animations": "^5.0.0",
"@angular/cdk": "^5.2.3",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/material": "^5.2.3",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/platform-server": "^4.3.6",
"@angular/router": "^5.0.0",
"@fortawesome/angular-fontawesome": "0.1.0-9",
"@fortawesome/fontawesome-svg-core": "^1.2.0-11",
"@fortawesome/free-brands-svg-icons": "^5.1.0-8",
"@fortawesome/free-solid-svg-icons": "^5.1.0-8",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.8",
"@ng-idle/core": "^2.0.0-beta.15",
"@ng-idle/keepalive": "^2.0.0-beta.15",
"@nguniversal/express-engine": "^1.0.0-beta.3",
"@nguniversal/module-map-ngfactory-loader": "^1.0.0-beta.3",
"@ngx-cache/core": "^4.0.1",
"@nicky-lenaers/ngx-scroll-to": "^0.6.0",
"angular-calendar": "^0.24.1",
"angular-fontawesome": "^1.0.0",
"angular-star-rating": "^3.0.8",
"angular2-csv": "0.2.5",
"angular2-highcharts": "^0.5.5",
"angular2-jwt": "^0.2.3",
"angular2-moment": "^1.7.0",
"angular2-multiselect-dropdown": "2.5.0",
"angular2piwik": "^0.1.5-beta",
"body-parser": "^1.18.2",
"bootstrap": "4.0.0-beta.2",
"calendar-utils": "^0.1.2",
"core-js": "^2.5.1",
"express": "^4.16.2",
"file-saver": "^1.3.3",
"font-awesome": "^4.7.0",
"formdata-polyfill": "^3.0.10",
"grapesjs": "^0.14.10",
"grapesjs-preset-webpage": "^0.1.9",
"highcharts": "^6.0.2",
"howler": "^2.1.1",
"moment": "^2.19.1",
"moment-timezone": "^0.5.16",
"ng-click-outside": "^3.2.0",
"ng-recaptcha": "^3.0.5",
"ng2-charts": "^1.6.0",
"ng2-img-cropper": "^0.9.0",
"ng2-pdf-viewer": "^5.2.3",
"ngx-bootstrap": "^2.0.5",
"ngx-ckeditor": "^0.4.0",
"ngx-file-drop": "^2.0.2",
"ngx-google-places-autocomplete": "^2.0.1",
"ngx-infinite-scroll": "^0.8.2",
"ngx-perfect-scrollbar": "^5.3.1",
"ngx-toastr": "^6.5.0",
"robotjs": "^0.5.1",
"rxjs": "^5.5.2",
"socket.io": "^2.0.4",
"survey-angular": "^1.0.51",
"survey-jquery": "^1.0.51",
"surveyjs-editor": "^1.0.51",
"xlsx": "0.12.7",
"zone.js": "^0.8.14"
,
"devDependencies":
"@angular/cli": "1.5.6",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^5.0.0",
"@types/jasmine": "^2.5.52",
"@types/node": "^8.0.10",
"codelyzer": "~4.0.1",
"cpy-cli": "^1.0.1",
"http-server": "^0.10.0",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "^4.1.0",
"karma": "^2.0.4",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "^1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.3.2",
"reflect-metadata": "^0.1.10",
"ts-loader": "^2.3.7",
"ts-node": "~3.3.0",
"tslint": "~5.8.0",
"typescript": "~2.4.2"
【问题讨论】:
您能补充一些信息吗?操作系统、nodejs 版本、使用的包、出现错误的命令。最好是我们可以测试的包。 @DerAlex 我编辑了我的问题,我正在使用 npm run build 来创建构建 为什么必须使用本地 ng 而不是全局 ng 构建? 问题似乎出在 npm 和 node 而不是 Angular CLI。尝试将 Node 升级到 v 5.9.1 并重新安装 node_modules。我希望这会奏效。 @Himanshu 我已经在使用 node 版本 8.9.3 【参考方案1】:所以我在 ubuntu 18.04 上安装了 nvm、nodejs 8.9.3、npm 5.7.1。我遇到的第一个问题是,我无法从 package.json 安装包,必须使用 npm i npm@latest -g
将 npm 更新到最新版本。
下一次运行 npm 告诉我那里大约有 33 个漏洞,其中一些漏洞很高,所以我仍然无法安装软件包。经过npm update, npm audit fix, npm audit fix --force
之后,我终于可以安装这些软件包了。
然后我创建了一个新项目,将npx ng new projectname
移动到该文件夹并执行npm run build
。那行得通。
因此,首先我建议您更新到当前的 nodejs / npm 版本,然后更新软件包并尝试再次运行该构建。
【讨论】:
我有另一台具有相同配置的机器,并且在那台机器上一切都运行良好,为什么会发生这种情况,你知道吗? 也许在另一台机器上之前已经安装了依赖项,所以它仍然可以工作。也许某些依赖项是以其他方式安装的,或者在您当前的机器上可能缺少某些依赖项。很难说。但正如我在回答中提到的:请更新并重新安装您的依赖项并重试您的构建。希望它能解决您的问题。 我将我的 npm 版本更新到 6.9.0 但问题仍未解决 你不仅应该更新 npm,还应该更新 nodejs 版本和 package.json 文件中定义的项目依赖项。 如果还是不行:删除全局 node_modules 文件夹,删除项目 node_modules 文件夹,重新安装更新的依赖项,然后尝试运行你的项目。以上是关于在 Angular 5 中创建构建时出错的主要内容,如果未能解决你的问题,请参考以下文章