【发布时间】:2016-10-31 20:51:11
【问题描述】:
这是我的第一个 SO 帖子,所以请放轻松。
我正在尝试在 client 文件夹中部署一个嵌入了 Angular 2 的 Rails-API 应用程序,以便我可以一次性部署整个应用程序。但是,当使用git push heroku master 进行部署时,尽管应用无法部署,但构建“成功”。
首先我将我的 Angular 客户端应用程序链接到公用文件夹:
$ rm -rf public
$ ln -s client/dist public
然后我添加了以下构建包:
$ heroku buildpacks:add https://github.com/jasonswett/heroku-buildpack-nodejs
$ heroku buildpacks:add heroku/ruby
这是我的 package.json:
{
"name": "my_app",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"preinstall": "npm install -g node-gyp",
"heroku-postbuild": "ng build"
},
"private": true,
"dependencies": {
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/forms": "0.3.0",
"@angular/http": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"@angular/router": "3.0.0-rc.1",
"core-js": "^2.4.0",
"rxjs": "5.0.0-beta.11",
"ts-helpers": "^1.1.1",
"zone.js": "0.6.12",
"@types/jasmine": "^2.2.30",
"angular-cli": "1.0.0-beta.11-webpack.8",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "0.13.22",
"karma-chrome-launcher": "0.2.3",
"karma-jasmine": "0.3.8",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.3",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.0",
"awesome-typescript-loader": "2.2.1"
},
"devDependencies": {
}
}
按照this问题帖子的建议将"awesome-typescript-loader": "2.2.1"添加到package.json依赖项也没有解决错误。
仅供参考,我一直在关注 Jason Swett 的这个主题指南:How to Deploy a Rails Application with an Angular CLI Webpack Front-End
git push heroku master之后的日志相关部分:
{...}
re34ms emitting
remote: Hash: 8b0f868d8f0eb54b494b
remote: Version: webpack 2.1.0-beta.21
remote: Time: 10807ms
remote: Asset Size Chunks Chunk Names
remote: main.bundle.js 2.51 MB 0, 2 [emitted] main
remote: styles.bundle.js 10.2 kB 1, 2 [emitted] styles
remote: inline.js 5.53 kB 2 [emitted] inline
remote: main.map 3.12 MB 0, 2 [emitted] main
remote: styles.map 14.2 kB 1, 2 [emitted] styles
remote: inline.map 5.59 kB 2 [emitted] inline
remote: index.html 472 bytes [emitted]
remote: chunk {0} main.bundle.js, main.map (main) 2.46 MB {1} [initial] [rendered]
remote: chunk {1} styles.bundle.js, styles.map (styles) 9.96 kB {2} [initial] [rendered]
remote: chunk {2} inline.js, inline.map (inline) 0 bytes [entry] [rendered]
remote:
remote: ERROR in [default] /tmp/build_26074be1021be2d930cc2ecb8ff54a9a/client/src/app/app.component.ts:5:12
remote: Cannot find name 'require'.
remote:
remote: ERROR in [default] /tmp/build_26074be1021be2d930cc2ecb8ff54a9a/client/src/app/app.component.ts:6:11
remote: Cannot find name 'require'.
remote: Child html-webpack-plugin for "index.html":
remote: Asset Size Chunks Chunk Names
remote: index.html 2.81 kB 0
remote: chunk {0} index.html 339 bytes [entry] [rendered]
{...}
为了调试此问题,是否有任何其他相关信息需要了解?
【问题讨论】:
-
您需要为 typescript 定义 require 才能知道,请参阅github.com/TypeStrong/…
标签: ruby-on-rails angularjs heroku deployment