I’ve been using npm install react-financial-charts
successfully. However, I want to include this package locally instead (for reasons), so I checked out the master branch of react-financial-charts
from Github. I now have two folders:
C:Usersuserprojectsreact-financial-charts // fresh checkout from Github C:Usersuserprojectsmyproject // my project
Inside of my project, my package.json
contains:
"dependencies": { "react-financial-charts": "file:C:/Users/user/projects/react-financial-charts" }
npm run dev
will now encounter the compile error corresponding to a basic import statement import { BarSeries } from "react-financial-charts"
in one of my files:
Module not found: Error: Can't resolve 'react-financial-charts' in 'C:UsersuserprojectsmyprojectsrcApp'
So basically, the simple import statement which used to work (when I was doing npm install react-financial-charts
), is now no longer working when I install the dependency from a local folder instead.
EDIT: I also tried these things that an answer below suggested, but I’m getting the exact same error message:
npm link ../react-financial charts
npm install ../react-financial charts
npm install --save ../react-financial charts
EDIT 2: This ended up working, thanks to the suggested answer below. The trick was I needed to npm update
and npm install
inside the dependency before linking.
cd react-financial-charts npm link cd ../myproject npm link react-financial-charts
Advertisement
Answer
Method 1: Using npm-link
Go to C:Usersuserprojectsreact-financial-charts
in terminal:
npm link
Now, go to your project C:Usersuserprojectsmyproject
:
npm link react-financial-charts
Now, any changes to C:Usersuserprojectsreact-financial-charts
will be reflected in C:Usersuserprojectsmyproject
. Note that the link should be to the package name, not the directory name for that package.
Method 2: Saving local repo as npm-install
npm install --save ../path/to/mymodule