我已经运行了很多次此应用程序,但是我在各处进行一些更改以帮助它在heroku而不是仅在我的应用程序上运行时,我已经开始收到此错误
...packages\backend\dist\main.js:1
import * as tslib_1 from "tslib"; SyntaxError: Unexpected token *
奇怪的是,我什至没有在打字稿中使用tslib 1;因此它是在构建时自动生成的,但是当我尝试从生产环境运行该应用程序时,它会挂起。
这是我的tsconfig.json
{
"compilerOptions":{
"target":"esnext",
"moduleResolution":"node",
"module":"esnext",
"declaration":false,
"noLib":false,
"emitDecoratorMetadata":true,
"experimentalDecorators":true,
"sourceMap":true,
"pretty":true,
"allowUnreachableCode":true,
"allowUnusedLabels":true,
"noImplicitAny":true,
"noImplicitReturns":false,
"noImplicitUseStrict":false,
"outDir":"dist/",
"baseUrl":"src/",
"listFiles":false,
"importHelpers": true,
"noEmitHelpers":true
},
"include":[
"src/**/*"
],
"exclude":[
"node_modules"
],
"compileOnSave":false
我相信我可能已经更改了tsconfig.json的重要内容,但是我不知道是什么!请帮忙!
答案 0 :(得分:1)
实际上,当您使用nodejs在服务器端进行开发时,必须使用
来设置tsconfig
"module": "commonjs"
要知道"None", "CommonJS", "AMD", "System", "UMD", "ES6", "ES2015" or "ESNext"
我建议您阅读本文https://medium.com/computed-comparisons/commonjs-vs-amd-vs-requirejs-vs-es6-modules-2e814b114a0b
答案 1 :(得分:0)
不知道为什么会这样,但是我做了以下更改
"module":"commonjs",
"target":"es6",
同样,不确定为什么会起作用,但是确实可以...