Running a script in a solid start project

Hi, I'd like to run a script, to seed my db, in a solid start project. I thought id just be able to npx ts-node src/foo.ts but I get an error TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" Any ideas on how to get this to work? TIA.
2 Replies
vibeman1987
vibeman198713mo ago
Can you send over your package.json? you can also add esModuleInterop to your tsconfig.json:
{
"compilerOptions": {
"esModuleInterop": true,
}
}
{
"compilerOptions": {
"esModuleInterop": true,
}
}
if even that doesn't work,
ts-node --esm src/foo.ts
ts-node --esm src/foo.ts
Julio Barros
Julio Barros13mo ago
Thanks. I have esModuleInterop set to true and have tried the --esm flag and have tried removing the "type" : module setting but none of that works.
{
"name": "PM2K",
"scripts": {
"dev": "solid-start dev",
"build": "solid-start build",
"start": "solid-start start"
},
"type": "module",
"devDependencies": {
"@types/node": "^20.8.7",
"@types/pg": "^8.10.7",
"drizzle-kit": "^0.19.13",
"esbuild": "^0.19.5",
"postcss": "^8.4.28",
"solid-start-node": "^0.3.7",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"vite": "^4.4.9"
},
"dependencies": {
"@modular-forms/solid": "^0.20.0",
"@solidjs/meta": "^0.28.6",
"@solidjs/router": "^0.8.3",
"drizzle-orm": "^0.28.6",
"pg": "^8.11.3",
"solid-bootstrap": "^1.0.18",
"solid-js": "^1.8.1",
"solid-start": "^0.3.7",
"valibot": "^0.19.0"
},
"engines": {
"node": ">=18"
}
}
{
"name": "PM2K",
"scripts": {
"dev": "solid-start dev",
"build": "solid-start build",
"start": "solid-start start"
},
"type": "module",
"devDependencies": {
"@types/node": "^20.8.7",
"@types/pg": "^8.10.7",
"drizzle-kit": "^0.19.13",
"esbuild": "^0.19.5",
"postcss": "^8.4.28",
"solid-start-node": "^0.3.7",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"vite": "^4.4.9"
},
"dependencies": {
"@modular-forms/solid": "^0.20.0",
"@solidjs/meta": "^0.28.6",
"@solidjs/router": "^0.8.3",
"drizzle-orm": "^0.28.6",
"pg": "^8.11.3",
"solid-bootstrap": "^1.0.18",
"solid-js": "^1.8.1",
"solid-start": "^0.3.7",
"valibot": "^0.19.0"
},
"engines": {
"node": ">=18"
}
}
Want results from more Discord servers?
Add your server