Search code examples
node.jstypescriptpackage.jsonts-nodemikro-orm

mikro-orm CLI: Cannot find module 'ts-node'


I'm attempting to use the mikro-orm CLI but am getting a ts-node error:

 $ npx mikro-orm debug
npx: installed 280 in 14.531s
(node:19228) UnhandledPromiseRejectionWarning: Error: Cannot find module 'ts-node'Require stack:
- C:\tmp\nodejs\npm-cache\_npx\19228\node_modules\mikro-orm\dist\cli\CLIHelper.js 
- C:\tmp\nodejs\npm-cache\_npx\19228\node_modules\mikro-orm\dist\cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1080:15)  
    at Function.Module._load (internal/modules/cjs/loader.js:923:27)
    at Module.require (internal/modules/cjs/loader.js:1140:19)
    at require (internal/modules/cjs/helpers.js:75:18)

  

My package.json has the following:

"scripts": {
    "watch": "tsc -w",
    "dev": "nodemon dist/index.js",
    "start": "node dist/index.js",
    "dev2": "nodemon --exec ts-node src/index.ts",
    "start2": "ts-node src/index.ts",
    "test": "echo \"Error: no test specified\" && exit 1",
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/node": "^14.6.3",
    "nodemon": "^2.0.4",
    "ts-node": "^9.0.0",
    "typescript": "^4.0.2"
  },
  "dependencies": {
    "@mikro-orm/cli": "^4.0.0-alpha.0",
    "@mikro-orm/core": "^4.0.0-alpha.0",
    "@mikro-orm/migrations": "^4.0.0-alpha.0",
    "@mikro-orm/postgresql": "^4.0.0-alpha.0",
    "pg": "^8.3.3"
  },
  "mikro-orm": {
    "useTsNode": true,
    "configPaths": [
      "./src/mikro-orm.config.ts",
      "./dist/mikro-orm.config.js"
    ]
  }

I'm using the 'watch' and 'dev' scripts to run currently, ts-node also works fine with the script 'start2'

My folder structure is: https://i.sstatic.net/7BGMT.png

This is new to me and I can't figure out what the problem is. Do you know what it could be?

Thank You!


Solution

  • answered by @MartinAdámek 'Upgrade all packages to latest version, you are on the very first alpha, latest is rc.6'