I'm using the rc-slider component in my application and had to add one feature to meet my needs.
I forked the main repository and pushed my changes to this branch.
In the application, I changed the package.json
as below and ran the npm install again:
"rc-slider": "Rodrigora/slider#add-label"
Nothing changed. Seems that npm doesn't update the dependencies.
So, I removed the node_modules
and rails cache folder and ran the install command again:
rm -rf node_modules/
rake tmp:cache:clear
npm install
Now, I have this error:
events.js:142
throw er; // Unhandled 'error' event
^
Error: Cannot find module 'rc-slider' from '/Users/rodrigora/project/app/assets/javascripts'
NPM can't find the rc-slider
when I using the modified branch.
package.json
file?You can use patch-package to make and persist changes to node modules. This can be done by first making changes to the package inside node_modules and then running the following command, with <package name> being the name of the package you just made changes to.
Open package. json , to to the "devDependencies" or "dependencies" key and add your package in the following format: "package-name": "username/repo#branch-name", And then install the package with npm install or yarn .
You should not include folder node_modules in your . gitignore file (or rather you should include folder node_modules in your source deployed to Heroku). If folder node_modules: exists then npm install will use those vendored libraries and will rebuild any binary dependencies with npm rebuild .
In npm docs:
"dependencies": {
"rc-slider": "git://github.com/Rodrigora/slider.git#add-label"
}
Also you can use
npm install git://github.com/Rodrigora/slider.git#add-label --save
The above command will add that dependency in your package.json
.
Edit:
I miss understood your question. I tried the below fix in the repo that you mentioned and it worked. (you should also have the dependency setup like above)
It is a react project. It is compiled and published to NPM.
So, if you want to install it directly from your github fork, you should make some changes to package.json
Before making changes in package.json
install rc-tools globaly:
sudo npm install rc-tools -g
Change the files that should be included:
"files": [
"index.js",
"assets",
"src"
]
and add postinstall
script in scripts:
"postinstall": "rc-tools run compile"
Then try installing from github after making these changes in that branch.
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