Heroku - 没有bower_components文件夹
问题描述:
我正在向Heroku部署一个Angular应用程序,并且需要添加Angular组件和其他一些功能。部署正在进行,除部署的站点以外的所有内容都缺少bower_components文件夹。我已经经历了一切,并阅读了许多*帖子,但我一定错过了一些东西。这里是我的代码:Heroku - 没有bower_components文件夹
的package.json
{
"name": "my-webapp",
"version": "1.0.0",
"main": "app.js",
"dependencies": {
"bower": "^1.8.0",
"express": "^4.15.2"
},
"devDependencies": {},
"scripts": {
"start": "node web.js",
"postinstall": "./node_modules/bower/bin/bower install"
},
"repository": {
"type": "git",
"url": "git+https://github.com...."
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com..."
},
"homepage": "https://github.com...",
"description": ""
}
web.js
var express = require('express'),
app = express();
app.use(express.static(__dirname));
app.get('/', function(req, res) {
res.sendfile('index.html', {root: __dirname })
});
var server = app.listen(process.env.PORT || 80);
Procfile
web: node web.js
bower.json
{
"name": "my-webapp",
"description": "",
"main": "app.js",
"authors": [
"Me"
],
"license": "ISC",
"homepage": "https://my-webapp.herokuapp.com/",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"angular-material-icons": "^0.7.1",
"angular-material": "^1.1.1",
"materialize": "^0.97.8",
"ng-lodash": "^0.5.0"
}
这里是生成输出,编辑亮点:
-----> Building dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
[email protected] /tmp/build_9a163093ad395af381c984026f6a5742/me-my-webapp-bfae0f9/node_modules/bower
[email protected] /tmp/build_9a163093ad395af381c984026f6a5742/mugwag-my-webapp-bfae0f9/node_modules/express
-----> Caching build
Clearing previous node cache
Saving 2 cacheDirectories (default):
- node_modules
- bower_components
-----> Build succeeded!
-----> Rebuilding any native dependencies
[email protected] /tmp/build_9a163093ad395af381c984026f6a5742/me-my-webapp-bfae0f9/node_modules/bower
[email protected] /tmp/build_9a163093ad395af381c984026f6a5742/me-my-webapp-bfae0f9/node_modules/express
????????? [email protected]
npm WARN [email protected] No description
-----> Found bower.json, running bower install
-----> Installing dependencies
> [email protected] postinstall /tmp/build_9a163093ad395af381c984026f6a5742/me-my-webapp-bfae0f9
> ./node_modules/bower/bin/bower install
npm WARN [email protected] No description
对我来说,它看起来好像一切正常,但是当我加载页面,我得到断开链接到bower_components的负载文件夹是这样的:
不能得到/bower_components/materialize/dist/css/materialize.css
没有亭子文件夹。为什么!?
答
仅供参考 - 我从未解决过这个问题,但现在使用Amazon S3来托管Angular应用程序。因为Angular完全是客户端,所以不需要服务器。只需将代码上传到S3或类似的普通主机并直接引用即可。
我希望能帮助别人。