【问题标题】:EXPORT not working in ts file node app deployed in pm2EXPORT 在 pm2 中部署的 ts 文件节点应用程序中不起作用
【发布时间】:2019-05-06 20:35:55
【问题描述】:

在 pm2 中部署我的应用程序时出现以下错误。 此错误出现在 Prisma.ts 文件中。

05-12-2018 15:53:34: export interface Query {
05-12-2018 15:53:34: ^^^^^^
05-12-2018 15:53:34: 
05-12-2018 15:53:34: SyntaxError: Unexpected token export
05-12-2018 15:53:34:     at new Script (vm.js:79:7)
05-12-2018 15:53:34:     at createScript (vm.js:251:10)
05-12-2018 15:53:34:     at Object.runInThisContext (vm.js:303:10)
05-12-2018 15:53:34:     at Module._compile (internal/modules/cjs/loader.js:657:28)
05-12-2018 15:53:34:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
05-12-2018 15:53:34:     at Module.load (internal/modules/cjs/loader.js:599:32)
05-12-2018 15:53:34:     at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
05-12-2018 15:53:34:     at Function.Module._load (internal/modules/cjs/loader.js:530:3)
05-12-2018 15:53:34:     at Module.require (internal/modules/cjs/loader.js:637:17)
05-12-2018 15:53:34:     at require (internal/modules/cjs/helpers.js:20:18)
05-12-2018 15:53:34: /home/user/Publish/PracticeBusiness/src/generated/prisma.ts:6

请帮帮我。

提前致谢。

【问题讨论】:

  • 您的代码似乎有语法错误,请正确检查您的代码
  • @aa 我认为这是另一个问题,因为它是一个带有 .ts extn 的类型脚本文件,错误出现在 import '{' 之后。
  • 在没有 pm2 的情况下运行应用程序时遇到同样的错误
  • 我克服了错误但又遇到了另一个,
  • 哦,你也可以在这里发帖:P

标签: node.js typescript pm2 prisma


【解决方案1】:

问题是我没有使用编译文件(.js),而是使用(.ts)文件 并尝试在节点包中托管。

这里的诀窍是使用 typescript 编译器并将 .ts 文件转换为 .js,一切都对我有用。

注意:在 VS 代码中使用 tsc 进行转换。

【讨论】:

    猜你喜欢
    • 2019-06-24
    • 1970-01-01
    • 2018-02-16
    • 2018-03-01
    • 1970-01-01
    • 2013-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多