Skip to main content

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:

  1. In your package.json file, specify the library version number and add a script to copy the necessary files from node_modules/charting_library/. The code sample below uses the public directory as the destination, but this may vary based on your project structure. Adjust the copy-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"
    }
    }
  2. Run npm install. This will also trigger the postinstall script, which copies the static files into the specified directory.

    info

    The 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.