Tsed: Cannot find module 'tsconfig-paths/register'

Created on 5 Feb 2021  ·  11Comments  ·  Source: tsedio/tsed

Information

  • Version: 6.24.2 (using ts-node ver. 9.1.1, typescript ver. 4.1.3)

A few sentences describing the overall goals of the issue.
Running the development server using yarn start ("tsnd --inspect --ignore-watch node_modules --respawn --transpile-only -r tsconfig-paths/register src/index.ts") throws error.

Example

❯ yarn start
yarn run v1.22.10
warning package.json: No license field
$ tsnd --inspect --ignore-watch node_modules --respawn --transpile-only -r tsconfig-paths/register src/index.ts
[INFO] 00:47:24 ts-node-dev ver. 1.1.1 (using ts-node ver. 9.1.1, typescript ver. 4.1.3)
Debugger listening on ws://127.0.0.1:9229/7cdfe72b-2136-49c0-8940-e3971d297e43
For help, see: https://nodejs.org/en/docs/inspector
Error: Cannot find module 'tsconfig-paths/register'
Require stack:
- internal/preload
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at Module._preloadModules (internal/modules/cjs/loader.js:1217:12)
    at loadPreloadModules (internal/bootstrap/pre_execution.js:449:5)
    at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:76:3)
    at internal/main/run_main_module.js:7:1

Missing tsconfig-paths in dev-dep

Was able to get it running by adding the above missing module

yarn add --dev tsconfig-paths
bug

Most helpful comment

Hello @classical-bit
this options is already implemented when you select the linter option:
Capture d’écran 2021-02-08 à 12 56 34

^^

All 11 comments

Hello @classical-bit
This issue is for the cli right?

Yes @Romakita. Should I close this one & re-open this issue in tsed-cli?

No worries, It’s to be sure ^^.

if you are interested to fix this issue and make a PR, you just have to edit the InitCommand.ts and add the missing devDependencies, then run test « yarn install & yarn test » and update the expected result. (10minutes ;) )

interested?

Super interested! I am on it. Thank you! @Romakita

Added it into dev-dep. PR: https://github.com/TypedProject/tsed-cli/pull/75
But the test didn't break, I checked but didn't find any assertions for dev dependencies. Might require some changes in tsed/cli-testing.

And thanks so much for helping me out.

I already merged the fix.

You've probably right, the Cli-testing isn't correct but the fix isn't simple.

So we can mock the projectPackageJson.write method to solve you problem :)

If you add this mock, you should have the expected result (https://github.com/TypedProject/tsed-cli/blob/master/packages/cli/test/integrations/init/init.integration.spec.ts#L30):

    it("should generate a project with the right options", async () => {
      const cliService = CliPlatformTest.get<CliService>(CliService);
      const projectPackageJson = CliPlatformTest.get<ProjectPackageJson>(ProjectPackageJson);

      jest.spyOn(projectPackageJson, "write").mockImplementation(function mock() {
        return this.fs.writeFileSync(this.path, JSON.stringify(this.raw, null, 2), {encoding: "utf8"});
      })

Can you add this on your branch, update unit test and create a new PR please ;)

See you
Romain

Aye captain, I'll share the new PR asap.

Thanks a lot @classical-bit ;)
If you have also any idea to improve the CLI (feature, concept... etc..), tell me!

@Romakita I was thinking of a minor feature of providing an option in CLI to setup pre-commit hooks for the test, lint, etc.

Hello @classical-bit
this options is already implemented when you select the linter option:
Capture d’écran 2021-02-08 à 12 56 34

^^

Was this page helpful?
0 / 5 - 0 ratings