Answer the question
In order to leave comments, you need to log in
Node.js - ts-node: Unexpected token ':'?
I am writing a backend server for my application and decided to change the executor from babel-node to ts-node . My command in package.json :
"server": "cd server && ts-node --project tsconfig.json -r ts-node/register Server.ts",
> [email protected] server D:\Projects\Visual Studio Code\NodeJS Server
> cd server && ts-node --project tsconfig.json -r ts-node/register Server.ts
(node:3824) ExperimentalWarning: The ESM module loader is experimental.
SyntaxError: Unexpected token ':'
at Loader.moduleStrategy (internal/modules/esm/translators.js:83:18)
at link (internal/modules/esm/module_job.js:36:21)
var test: string = 'Hello!';
console.log(test);
PS D:\Projects\Visual Studio Code\NodeJS Server\server> npx ts-node test.ts
(node:1420) ExperimentalWarning: The ESM module loader is experimental.
SyntaxError: Unexpected token ':'
at Loader.moduleStrategy (internal/modules/esm/translators.js:83:18)
at link (internal/modules/esm/module_job.js:36:21)
{
"compilerOptions": {
"target": "ES6",
"moduleResolution": "Node",
"traceResolution": false,
"allowJs": false,
"esModuleInterop": true,
"declaration": false,
"noResolve": false,
"noImplicitAny": false,
"removeComments": true,
"strictNullChecks": false,
"sourceMap": false,
"skipLibCheck": true,
"resolveJsonModule": true,
"typeRoots": [
"custom_typings",
"node_modules/@types",
],
},
"include": [
"client",
"server",
],
"exclude": [
"node_modules",
"client/bundle.js"
]
}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"jsx": "preserve",
"noEmit": true,
"baseUrl": "../",
"paths": {
"*": ["node_modules/*"],
"@server/*": ["server/*"],
"@client/*": ["client/*"],
"@routes/*": ["server/routes/*"],
"@public/*": ["public/*"],
"@secure/*": ["secure/*"],
"@utils/*": ["utils/*"],
},
},
"include": ["**/*"]
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question