Reputation: 4055
I'm trying to use a NPM package which i downloaded from GitHub, but having no luck.
I created a lib
folder in my src directory of my create-react-app project.
Then i used wget to download the tarball
wget https://github.com/frontend-collective/react-image-lightbox/tarball/master/master.tar.gz
I then changed the name of the tarball
mv master.tar.gz react-image-lightbox-5.2.0.tar.gz
Then I installed the package using NPM
npm install ./src/lib/react-image-lightbox-5.2.0.tar.gz
In my package.json it shows;
"react-image-lightbox": "file:src/lib/react-image-lightbox-5.2.0.tar.gz",
So that all worked nicely.
But when i try and import the package using;
import Lightbox from 'react-image-lightbox';
i get the following error message when doing a npm run build
Cannot find module: 'react-image-lightbox'. Make sure this package is installed.
You can install this package by running: npm install react-image-lightbox.
Im missing something but I cant figure out what.
Any help would be greatly appreciated.
Upvotes: 2
Views: 1926
Reputation: 20256
It is not necessary to get the code from GitHub you want manually by using wget
and mv
.
You can install the master version of the repository by using its Git clone URL:
npm install --save https://github.com/frontend-collective/react-image-lightbox.git
The resulting package.json
file will look something like this:
{
"name": "hello-world",
"version": "0.0.1",
"dependencies": {
"react-image-lightbox": "git+https://github.com/frontend-collective/react-image-lightbox.git"
}
}
You can then use the package like you would use the regular one:
import Lightbox from 'react-image-lightbox';
Upvotes: 2