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

fix(scripts): use ts-node for start script #2052

Closed
wants to merge 1 commit into from

Conversation

caugner
Copy link
Contributor

@caugner caugner commented Jan 2, 2025

Before

% npm start

> [email protected] start
> node app.js

node:internal/modules/cjs/loader:1228
  throw err;
  ^

Error: Cannot find module '/Users/claas/github/openwebdocs/mdn-bcd-collector/app.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.18.0

After

% npm start

> [email protected] start
> node --loader=ts-node/esm --no-warnings=ExperimentalWarning app.ts

info: Listening on port 8080 (HTTP)
info: Press Ctrl+C to quit.

@queengooborg
Copy link
Member

ts-node is a dev dependency and is not available in production environments. The expectation for production is to build everything first on a development environment, then run the built version in production, which is what Heroku does. (I also had problems with trying to use ts-node in Heroku's production environment.)

TLDR, the start script should not use ts-node. Developers should always use npm run dev, but if they absolutely must run npm start, run npm build first.

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

Successfully merging this pull request may close these issues.

2 participants