gpt4 book ai didi

node.js - 无法将 Node.js 应用程序编译到 heroku

转载 作者:太空宇宙 更新时间:2023-11-04 02:09:14 26 4
gpt4 key购买 nike

你好。我有一个奇怪的错误。我最近在笔记本电脑上重新安装了所有内容。现在我遇到了麻烦。每次我使用 package.json 中的此配置时,推送到 heroku 都会出错。

  {
"name": "mrfrederiksen",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"postinstall": "ng build --aot -prod",
"start": "node server.js"
},
"engines": {
"node": "7.7.3",
"npm": "4.1.2"
},
"private": true,
"dependencies": {
"@angular/cli": "1.0.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"core-js": "^2.4.1",
"express": "^4.15.2",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
}

但是...如果我使用安装了旧版本的 friend 提供的此功能,则一切正常。

{
"name": "mrfrederiksen",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"postinstall": "ng build --aot -prod",
"start": "node server.js"
},
"engines": {
"node": "6.9.4",
"npm": "3.10.10"
},
"private": true,
"dependencies": {
"@angular/cli": "1.0.0-rc.0",
"@angular/common": "^2.4.0",
"@angular/compiler": "^2.4.0",
"@angular/core": "^2.4.0",
"@angular/forms": "^2.4.0",
"@angular/http": "^2.4.0",
"@angular/platform-browser": "^2.4.0",
"@angular/platform-browser-dynamic": "^2.4.0",
"@angular/router": "^3.4.0",
"core-js": "^2.4.1",
"express": "^4.15.2",
"rxjs": "^5.1.0",
"zone.js": "^0.7.6"
},
"devDependencies": {
"@angular/compiler-cli": "^2.4.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.4.2",
"typescript": "~2.0.0"
}
}

这是我在使用我自己的最新版本时出现的错误控制台消息。

-----> Node.js app detected
-----> Creating runtime environment

NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 7.7.3
engines.npm (package.json): 4.1.2

Downloading and installing node 7.7.3...
npm 4.1.2 already installed with node
-----> Restoring cache
Skipping cache restore (new runtime signature)
-----> Building dependencies
Installing node modules (package.json)

> node-sass@4.5.1 install /tmp/build_5a8b797790355e544758529cdf0f5b1a/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.1/linux-x64-51_binding.node
Download complete
Binary saved to /tmp/build_5a8b797790355e544758529cdf0f5b1a/node_modules/node-sass/vendor/linux-x64-51/binding.node
Caching binary to /app/.npm/node-sass/4.5.1/linux-x64-51_binding.node

> node-sass@4.5.1 postinstall /tmp/build_5a8b797790355e544758529cdf0f5b1a/node_modules/node-sass
> node scripts/build.js

Binary found at /tmp/build_5a8b797790355e544758529cdf0f5b1a/node_modules/node-sass/vendor/linux-x64-51/binding.node
Testing binary
Binary is fine

> mrfrederiksen@0.0.0 postinstall /tmp/build_5a8b797790355e544758529cdf0f5b1a
> ng build --aot -prod

The "@angular/compiler-cli" package was not properly installed.
Error: The "@angular/compiler-cli" package was not properly installed.
at Object.<anonymous> (/tmp/build_5a8b797790355e544758529cdf0f5b1a/node_modules/@ngtools/webpack/src/index.js:14:11)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/tmp/build_5a8b797790355e544758529cdf0f5b1a/node_modules/@angular/cli/tasks/eject.js:10:19)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)

npm ERR! Linux 3.13.0-112-generic
npm ERR! argv "/tmp/build_5a8b797790355e544758529cdf0f5b1a/.heroku/node/bin/node" "/tmp/build_5a8b797790355e544758529cdf0f5b1a/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_5a8b797790355e544758529cdf0f5b1a/.npmrc"
npm ERR! node v7.7.3
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! mrfrederiksen@0.0.0 postinstall: `ng build --aot -prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mrfrederiksen@0.0.0 postinstall script 'ng build --aot -prod'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the mrfrederiksen package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ng build --aot -prod
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs mrfrederiksen
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls mrfrederiksen
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /tmp/build_5a8b797790355e544758529cdf0f5b1a/npm-debug.log
-----> Build failed

We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys

If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/

Love,
Heroku

! Push rejected, failed to compile Node.js app.
! Push failed

最佳答案

将 npm、node、typescript 和 ng-cli 升级到最新版本后,我遇到了类似的问题。尝试了很多事情但没有任何结果。

(ended up with "The "@angular/compiler-cli" package was not properly installed" error).

然后执行以下步骤:

  1. 使用新版本创建新项目 (ng new [project_name])
  2. 使用“npm start”成功启动上面创建的未编写任何代码的项目
  3. 将旧项目的“src”文件夹复制到新项目文件夹中
  4. 将旧项目中的文件夹( Bootstrap )复制到新项目文件夹中
  5. 使用“npm start”启动项目

一切开始照常进行。

关于node.js - 无法将 Node.js 应用程序编译到 heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42998551/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com