{"record":{"id":"b0db22fbc4670e05","repo":"medusajs/medusa","slug":"ts-node-cannot-be-loaded-and-used-if-you-are-runn","errorCode":null,"errorMessage":"ts-node cannot be loaded and used, if you are running in production don't forget to set your NODE_ENV to production","messagePattern":"ts-node cannot be loaded and used, if you are running in production don't forget to set your NODE_ENV to production","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/medusa-cli/cli.js","lineNumber":9,"sourceCode":"#!/usr/bin/env node\n\ntry {\n  require(\"ts-node\").register({})\n  require(\"tsconfig-paths\").register({})\n} catch (e) {\n  const isProduction = process.env.NODE_ENV === \"production\"\n  if (!isProduction) {\n    console.warn(\n      \"ts-node cannot be loaded and used, if you are running in production don't forget to set your NODE_ENV to production\"\n    )\n    console.warn(e)\n  }\n}\nrequire(\"dotenv\").config()\nrequire(\"./dist/index.js\")\n","sourceCodeStart":1,"sourceCodeEnd":17,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/cli/medusa-cli/cli.js#L1-L17","documentation":"The medusa-cli entry script tries to register ts-node and tsconfig-paths so it can run TypeScript source and resolve path aliases. If those modules are missing from node_modules (typically after a partial install or when a global install lacks devDependencies), it warns in non-production environments and falls back, which may cause later module-not-found errors for TS files or path aliases.","triggerScenarios":"Requiring ts-node or tsconfig-paths throws MODULE_NOT_FOUND because they were pruned from node_modules (e.g. production install) while NODE_ENV is not set to production.","commonSituations":"Running a globally installed medusa CLI against a project; NODE_ENV unset in a production deployment; yarn install --production pruning devDependencies.","solutions":["Set NODE_ENV=production when running in production so the warning is suppressed and behavior is expected","Ensure ts-node and tsconfig-paths are installed: npm/yarn install with devDependencies included","Prefer running the project-local medusa binary (npx medusa / yarn medusa) rather than a global install"],"exampleFix":"# before\nmedusa start\n\n# after (production)\nNODE_ENV=production medusa start","handlingStrategy":"fallback","validationCode":"if (process.env.NODE_ENV !== \"production\" && !require.resolve(\"ts-node\", { paths: [process.cwd()] })) {\n  console.warn(\"ts-node missing — run a full install with devDependencies\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set NODE_ENV=production in deployed environments","Install the CLI locally in the project rather than globally so devDependencies resolve"],"tags":["cli","ts-node","node-env","environment"],"backgroundTag":"missing-dev-dependency","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}