简体   繁体   English

导出不适用于pm2中部署的ts文件节点应用

[英]EXPORT not working in ts file node app deployed in pm2

I'm having the following error while deploying my application in pm2. 在pm2中部署应用程序时出现以下错误。 This error appears in the Prisma.ts file. 此错误出现在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

Please help me with this. 请帮我解决一下这个。

Thanks in advance. 提前致谢。

The issue was the I was not using the complied file(.js) instead i was using the (.ts) file and trying to host in node package. 问题是我没有使用编译的文件(.js),而是我正在使用(.ts)文件并尝试托管在节点程序包中。

The trick here was to use a typescript compiler and convert the .ts file to .js and everything worked for me. 这里的窍门是使用打字稿编译器,然后将.ts文件转换为.js,一切对我都有效。

Note: use tsc in VS code to do the conversion. 注意:在VS代码中使用tsc进行转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM