Where are auto-installed modules stored in filesystem?


#1

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>

#2

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:


#3

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.