NPM
You can install the library as an NPM dependency.
However, you need to manually host the static files that the library provides.
These files are located in node_modules/charting_library/
and can be automatically copied into your preferable directory during installation.
Follow the steps below to set it up:
In your
package.json
file, specify the library version number and add a script to copy the necessary files fromnode_modules/charting_library/
. The code sample below uses thepublic
directory as the destination, but this may vary based on your project structure. Adjust thecopy-files
command accordingly.{
"scripts": {
"postinstall": "npm run copy-files",
"copy-files": "cp -R node_modules/charting_library/ public"
},
"dependencies": {
"charting_library": "git@github.com:tradingview/charting_library.git#semver:28.0.0"
}
}Run
npm install
. This will also trigger thepostinstall
script, which copies the static files into the specified directory.infoThe library repository is private.
npm install
will only work if the Git client is logged into an account with access to the repository. Refer to Getting Access for more information.If you encounter installation issues, ensure your SSH public key is added to your GitHub account and set for verification. If the
ssh -T git@github.com
command works, your SSH is set up correctly.