【发布时间】:2019-12-05 09:47:09
【问题描述】:
我的 typescript 项目不会在我的 heroku 服务器上构建。
-----> Build
Running build
> back-end@1.0.0 build /tmp/build_32c5a59b6806145803516c50f84fc693
> tsc && node build/index.js
error TS5023: Unknown compiler option 'esModuleInterop'.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! back-end@1.0.0 build: `tsc && node build/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the back-end@1.0.0 build 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.DGTha/_logs/2019-07-27T07_56_31_141Z-debug.log
-----> Build failed
我能够在本地构建和运行应用程序。我本地的 tsc 版本是 3.5.1
但是在我的 heroku bash 中我明白了。
~ $ tsc -v
message TS6029: Version 1.5.3
即使我在 heroku 上的 package.json 看起来像这样:
~ $ cat package.json
{
"name": "back-end",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"precompile": "rimraf build",
"compile": "tsc && node build/index.js",
"dev": "nodemon --watch src/ --exec \"npm run compile\" --verbose -e ts",
"start": "tsc && node build/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@types/cookie-parser": "^1.4.1",
"@types/cors": "^2.8.5",
"@types/express": "^4.17.0",
"@types/jsonwebtoken": "^8.3.2",
"@types/mongoose": "^5.5.11",
"@types/node": "^12.6.8",
"@types/passport-local": "^1.0.33",
"axios": "^0.19.0",
"body-parser": "^1.18.3",
"cookie-parser": "^1.4.3",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"express": "^4.16.4",
"express-jwt": "^5.3.1",
"express-session": "^1.15.6",
"jsonwebtoken": "^8.4.0",
"mixer-client-node": "^2.7.1",
"mongoose": "^5.4.1",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"passport-mixer": "^1.0.1",
"tsc": "^1.20150623.0",
"uuid": "^3.3.2",
"ws": "^7.0.1"
},
"eslintConfig": {
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/indent": [
"error",
2
],
"linebreak-style": 0
}
},
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@typescript-eslint/eslint-plugin": "^1.13.0",
"@typescript-eslint/parser": "^1.13.0",
"concurrently": "^4.1.0",
"eslint": "^5.12.0",
"eslint-config-airbnb": "^17.1.1",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.12.3",
"eslint-watch": "^4.0.2",
"prettier": "^1.18.2",
"rimraf": "^2.6.3",
"typescript": "^3.5.3"
}
}
通知"tsc": "^1.20150623.0"。正如你所期望的,这与我的本地 package.json 完全相同。
但是当我在本地机器上运行 tsc -v 时,我得到了这个:
> tsc -v
Version 3.5.3
我尝试通过运行npm uninstall -g tsc 来解决此问题,然后通过heroku bash 重新安装。这并没有解决问题。
为什么我的 Heroku 服务器上的 tsc 版本如此过时?为什么默认全局安装 tsc? (我必须使用 npm 脚本来检查我机器上的版本)。如何在 heroku 上更新 tsc 并解决此问题?
【问题讨论】:
标签: typescript heroku