1

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:\Users\user\projects\react-financial-charts // fresh checkout from Github
C:\Users\user\projects\myproject // 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:\Users\user\projects\myproject\src\App'

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
1

1 Answer 1

3

Method 1: Using npm-link

Go to C:\Users\user\projects\react-financial-charts in terminal:

npm link

Now, go to your project C:\Users\user\projects\myproject:

npm link react-financial-charts

Now, any changes to C:\Users\user\projects\react-financial-charts will be reflected in C:\Users\user\projects\myproject. 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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.