Where are auto-installed modules stored in filesystem?

When I add a module to package.json where does it get installed? How do I refer to it later?

package.json:

"dependencies": {
    "d3": "*"
}

index.html:

<html><body>
<script src="/***what/goes/here?***/d3.v3.min.js"></script>
</html></body>

Easy fix here would be to use:

  • CDN
  • Have d3 in your scripts, but client-side

Maybe there’s a way using npm, but I’m not aware of it and may break in the future as they are changing stuff on how the back-end works. :confused:

Hi Jonathan,

the app runs in /app, and the modules are installed in /app/node_modules.

However, backend files are not served by default. You won’t be able to reference it in a script tag without first exposing it on the backend side. If you are using express, you can add add a “static” middleware that exposes the directories you want to be able to access.

2 Likes