genshindev / api

A fan-made Genshin Impact API for easy access to game data.
https://genshin.jmp.blue
Open Software License 3.0
710 stars 197 forks source link

fix: npm run dev #5

Closed ghost closed 3 years ago

ghost commented 3 years ago

Issue

/tmp » git clone https://github.com/genshindev/api.git && cd api/
/tmp/api(master) » npm i
[...]
/tmp/api(master*) » npm run dev

> @genshindev/api@1.0.0 dev /private/tmp/api
> nodemon

[nodemon] 2.0.6
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node dist/index.js`
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module '/private/tmp/api/dist/index.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
[nodemon] app crashed - waiting for file changes before starting...

What happen's nodemon looking for transpiled ts files in dist. But they won't exist on clean clone, nor will be updated while coding (dist/ updated on build only)

Solution

nodemon should be based on TS files for development purpose, so add ts-node, and watch those.