Heroku找不到ts节点

Heroku找不到ts节点

本文介绍了Heroku找不到ts节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在多人游戏中使用 Colyseus .该框架生成了一个打字稿服务器,我尝试将其部署到Heroku.我的日志中出现以下错误:

I am using Colyseus for my multiplayer game. The framework generated a typescript server which I tried to deploy to Heroku. I am getting the following error in my logs:

2019-08-18T09:45:55.362304+00:00 app[web.1]: npm ERR! syscall spawn
2019-08-18T09:45:55.363375+00:00 app[web.1]: npm ERR! [email protected] start: `ts-node index.ts`
2019-08-18T09:45:55.363477+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-08-18T09:45:55.363677+00:00 app[web.1]: npm ERR!
2019-08-18T09:45:55.363800+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2019-08-18T09:45:55.363912+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-08-18T09:45:55.373038+00:00 app[web.1]:
2019-08-18T09:45:55.373380+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-08-18T09:45:55.373520+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-08-18T09_45_55_365Z-debug.log

我的package.json:

{
  "name": "my-app",
  "version": "1.0.0",
  "description": "npm init template for bootstraping an empty Colyseus project",
  "main": "lib/index.js",
  "scripts": {
    "start": "ts-node index.ts",
    "loadtest": "colyseus-loadtest loadtest/example.ts --room my_room --numClients 2",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "UNLICENSED",
  "bugs": {
    "url": "https://github.com/colyseus/create-colyseus/issues"
  },
  "homepage": "https://github.com/colyseus/create-colyseus#readme",
  "devDependencies": {
    "@colyseus/loadtest": "^0.10.1",
    "@types/express": "^4.16.1",
    "ts-loader": "^5.3.3",
    "ts-node": "^8.1.0",
    "typescript": "^3.4.5"
  },
  "dependencies": {
    "@colyseus/monitor": "^0.10.0",
    "@colyseus/social": "^0.10.2",
    "colyseus": "^0.10.7",
    "express": "^4.16.4",
    "express-jwt": "^5.3.1"
  }
}

这是tsconfig.json:

{
  "compilerOptions": {
    "outDir": "lib",
    "target": "es6",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true,
    "experimentalDecorators": true
  }
}

为什么Heroku找不到ts-node?

Why can't Heroku find ts-node?

推荐答案

ts-node在您的devDependencies中列出,但开箱即用时,它们不可用:

运行安装和构建步骤后在部署应用程序之前,Heroku将删除在devDependencies下声明的软件包.

After running the installation and build steps Heroku will strip out the packages declared under devDependencies before deploying the application.

如果您在运行时需要ts-node,建议将其移至dependencies.

If you need ts-node at runtime I suggest moving it to your dependencies.

其他解决方案是仅在构建时使用它(我不确定ts-node是否可行,但可能涉及将TypeScript编译为JavaScript)或配置Heroku不剥离您的devDependencies .我强烈建议不要使用最后一个选项-生产中不需要devDependencies.

Other solutions would be to use it only at build time (I'm not sure if this is possible with ts-node but it would probably involve compiling your TypeScript to JavaScript) or configuring Heroku not to strip your devDependencies. I strongly advise against this last option—devDependencies shouldn't be required in production.

这篇关于Heroku找不到ts节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 05:23