MatrixAI / TypeScript-Demo-Lib

TypeScript Library Demo Project using Nix https://matrix.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The usage of `npm link`

CMCDragonkai opened this issue · comments

The npm link can be useful when developing multiple packages together without having to go through publishing overhead. The exact steps for our system is a bit complicated.

Tasks

  • 1. Add export npm_config_prefix=~/.npm to shell.nix, this ensures that ~/.npm is used for these links, and so it doesn't try to write it to the read-only path in /nix/store.
  • 2. Provide instructions that you must then provide tsconfig paths for the relevant package like with the package @matrixai/db (this unfortunately must be done manually)
      "paths": {
        "@": ["index"],
        "@/*": ["*"],
        "@matrixai/db": ["../node_modules/@matrixai/db/src"],
        "@matrixai/db/*": ["../node_modules/@matrixai/db/src/*"]
      },
    
  • 3. Explain how you now use npm link ../js-db, or use npm link in the js-db, then go back to js-polykey and use npm link @matrixai/db

Then you don't need to use npm run build, and you can reload window in vscode in case types must be updated.

@tegefaulkes this is what I'm doing right now with testnetprep.

Important that once your development process is over, to remove those properties from tsconfig.json as they no longer apply.