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
There are a few ways you can debug your Node.js programs in VS Code: Use auto attach to debug processes you run in VS Code's integrated terminal. Use the JavaScript debug terminal, similar to using the integrated terminal. Use a launch config to start your program, or attach to a process launched outside of VS Code.
debug exposes a function; simply pass this function the name of your module, and it will return a decorated version of console. error for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.
You can use npm link
your version of the code: https://docs.npmjs.com/cli/link.html
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With