os:windows server 2022
use "node_modules/.bin/ts-node index.ts " can start express service
use "pm2 start index.ts --interpreter node_modules/.bin/ts-node " can't start express service
pm2 log as below:
0|index | import express from 'express';
0|index | ^^^^^^
0|index |
0|index | SyntaxError: Cannot use import statement outside a module
0|index | at internalCompileFunction (node:internal/vm:73:18)
0|index | at wrapSafe (node:internal/modules/cjs/loader:1178:20)
0|index | at Module._compile (node:internal/modules/cjs/loader:1220:27)
0|index | at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
0|index | at Module.load (node:internal/modules/cjs/loader:1119:32)
0|index | at Module._load (node:internal/modules/cjs/loader:960:12)
os:windows server 2022 use "node_modules/.bin/ts-node index.ts " can start express service use "pm2 start index.ts --interpreter node_modules/.bin/ts-node " can't start express service pm2 log as below:
0|index | import express from 'express'; 0|index | ^^^^^^ 0|index | 0|index | SyntaxError: Cannot use import statement outside a module 0|index | at internalCompileFunction (node:internal/vm:73:18) 0|index | at wrapSafe (node:internal/modules/cjs/loader:1178:20) 0|index | at Module._compile (node:internal/modules/cjs/loader:1220:27) 0|index | at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) 0|index | at Module.load (node:internal/modules/cjs/loader:1119:32) 0|index | at Module._load (node:internal/modules/cjs/loader:960:12)
tsconfig.json as below: { "compilerOptions": { "module": "CommonJS", "esModuleInterop": true, "target": "ES2016", /"target": "es6",/ "rootDir": "./", "outDir": "./build", "strict": true },
}