reactjstypescriptnpmyarnpkgreact-select

Install a TypeScript package from GitHub repository subfolder


I'm using react-select on my ReactJS module, and I needed to make some changes to fit my needs.

But now, I'm trying to install my own fork using NPM, and it doesn't work.

Error message:

Module not found: Error: Can't resolve 'react-select'

Tried using gitpkg with the following commands, and it did not work.

npm install 'willnaoosmith/react-select'
npm install 'https://gitpkg.now.sh/willnaoosmith/react-select/packages/react-select?master'
npm install -B 'willnaoosmith/react-select'

The module uses TypeScript, and my changes are on the packages/react-select.

When I try to install it using npm install 'willnaoosmith/react-select' it creates a @react-select/monorepo entry on my package.json

When I try to install using npm install 'https://gitpkg.now.sh/willnaoosmith/react-select/packages/react-select?master' it doesn't create the dist folders on the directories inside node_modules/react-select/packages/react-select/

What am I missing?


Solution

  • If you only want to test your changes locally before publishing to ensure they work you can follow the steps below:

    Say, you're developing an app called A and B is the react-select package you made changes to locally, then:

    1. Go to the project folder for B and enter npm link - this will create a local package called B.
    2. Now go to your project (A) folder and enter npm link B - this will link your project to the local package (B).

    Any changes you make to B should reflect in A without having to publish it.

    Another option is to use your repository directory with the following steps:

    1. Push your code changes from your updated package to GitHub
    2. Tag the just pushed commit
    3. In your project, run npm install github_username/repository#tag

    You can see the following link for details