我正在尝试运行compress
(django compressor)以最小化CSS
个实例上的js
和Heroku
个文件,但我不能安装less
。
构建进度日志
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 4.1.1
engines.npm (package.json): unspecified (use default)
Downloading and installing node 4.1.1...
Using default npm version: 2.14.4
-----> Restoring cache
Loading 2 from cacheDirectories (default):
- node_modules (not cached - skipping)
- bower_components (not cached - skipping)
-----> Building dependencies
Installing node modules (package.json)
-----> Caching build
Clearing previous node cache
Saving 2 cacheDirectories (default):
- node_modules (nothing to cache)
- bower_components (nothing to cache)
-----> Build succeeded!
└── (empty)
-----> Python app detected
$ pip install -r requirements.txt
-----> Running post-compile hook
npm http GET https://registry.npmjs.org/less
npm http 200 https://registry.npmjs.org/less
npm http GET https://registry.npmjs.org/less/-/less-2.7.1.tgz
npm http 200 https://registry.npmjs.org/less/-/less-2.7.1.tgz
npm WARN engine less@2.7.1: wanted: {"node":">=0.12"} (current: {"node":"v0.8.12","npm":"1.1.63"})
npm http GET https://registry.npmjs.org/errno
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/image-size
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/promise
npm http GET https://registry.npmjs.org/source-map
npm http 200 https://registry.npmjs.org/mkdirp
npm http 200 https://registry.npmjs.org/mime
npm http 200 https://registry.npmjs.org/image-size
npm http 200 https://registry.npmjs.org/graceful-fs
npm WARN optional dep failed, continuing mkdirp@^0.5.0
npm WARN optional dep failed, continuing mime@^1.2.11
npm WARN optional dep failed, continuing graceful-fs@^4.1.2
npm http GET https://registry.npmjs.org/image-size/-/image-size-0.5.1.tgz
npm http 200 https://registry.npmjs.org/source-map
npm WARN optional dep failed, continuing source-map@^0.5.3
npm http 200 https://registry.npmjs.org/image-size/-/image-size-0.5.1.tgz
npm http 200 https://registry.npmjs.org/errno
npm WARN optional dep failed, continuing errno@^0.1.1
npm http 200 https://registry.npmjs.org/promise
npm WARN optional dep failed, continuing promise@^7.1.1
npm WARN engine image-size@0.5.1: wanted: {"node":">=0.10.0"} (current: {"node":"v0.8.12","npm":"1.1.63"})
less@2.7.1 node_modules/less
└── image-size@0.5.1
-----> Discovering process types
Procfile declares types -> web
-----> Compressing...
Done: 72.8M
-----> Launching...
Released v159
https://<my-app>.herokuapp.com/ deployed to Heroku
的package.json
{
"name": "myapp",
"description": "a really cool test",
"version": "1.0.0",
"engines": {
"node": "4.1.1"
}
}
post_compile hook
#!/usr/bin/env bash
export PATH=/app/.heroku/node/bin:$PATH
npm install less
为什么这不起作用?看起来Node.js
安装的正确版本已经安装,但之后会以某种方式从$PATH
中删除。我猜测$PATH
在多个构建包之间不是持久的。有什么想法吗?
答案 0 :(得分:0)
不确定为什么要在post_compile挂钩中安装less。 为什么不直接将它添加到你的package.json中,运行以下命令(在你的开发环境中),然后将修改后的package.json添加到推送到Heroku的git repo中:
npm install less --save