Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use pm2 start index.ts occur Error #5784

Open
painstgithub opened this issue Mar 16, 2024 · 1 comment
Open

use pm2 start index.ts occur Error #5784

painstgithub opened this issue Mar 16, 2024 · 1 comment

Comments

@painstgithub
Copy link

painstgithub commented Mar 16, 2024

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
},

}
image

@ultimate-tester
Copy link
Contributor

This is not related to PM2. You need to set your package type to module:
https://nodejs.org/api/packages.html#type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants