Reputation: 41725
Normally you yarn/npm install react
, then use it with import React from 'react'
Say you want to debug a React source and you clone a GitHub repo.
How do you use the source in your project instead of the lib version?
To further develop philipheinser's answer, here's what I encountered with doing npm link draft-js-mention-plugin
npm link
seems to run npm run build
which is the scripts
command in the package.json
that you want to link.
with draft-js-mention-plugin
, npm run build runs ../node_modules/.bin/rimraf lib
and I had to go up a directory and run npm install
to install the rimraf
draft-js-mention-plugin
has parent draft-js-plugins
and it has its own package.json
Upvotes: 10
Views: 15712
Reputation: 468
If you want to mimic a more production like situation you might use this workflow:
Create a package of your submodule locally:
cd /path/to/your/module
npm pack
This will create a .tgz file of your package in /path/to/your/module
Install the local package of the submodule in your application:
cd /path/to/your/application
npm install /path/to/your/module/<YourModule>-<YourModulesVersion>.tgz
This will install the .tgz file in your application's node_modules directory
These steps should be repeated after adjustments to your module.
Upvotes: 2
Reputation: 311
You can use npm link
your version of the code: https://docs.npmjs.com/cli/link.html
Upvotes: 4