【发布时间】:2018-08-04 23:23:09
【问题描述】:
我不想上传预编译的 dist 目录,而是想在服务器端编译 src。
这是我在 package.json 中的脚本:
"scripts": {
"test": "echo \"No test specified\" && exit 0",
"start": "node dist/app.js",
"postinstall": "tsc"
}
以下是依赖项:
"dependencies": {
"@types/express": "^4.11.1",
"@types/pg": "^7.4.4",
"@types/socket.io": "^1.4.31",
"body-parser": "^1.18.2",
"express": "^4.16.2",
"pg": "^7.4.1",
"socket.io": "^2.0.4",
"tslint": "^5.9.1",
"typescript": "^2.7.2"
}
由于'npm install会在安装过程中将node_modules/.bin文件夹添加到PATH环境变量中',所以Heroku应该可以直接调用它。
但这是我得到的错误:
Building dependencies
Installing node modules (package.json + package-lock)
> bilgi-yarismasi@1.0.0 postinstall /tmp/build_afa42c7943d4b71d2b48a016ae3b9e50
> tsc
sh: 1: tsc: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! bilgi-yarismasi@1.0.0 postinstall: `tsc`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the bilgi-yarismasi@1.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.LTxbD/_logs/2018-02-25T10_36_06_374Z-debug.log
-----> Build failed
【问题讨论】:
-
也可以查看my answer
标签: typescript heroku compilation tsc