Can you access node_modules?

Can you access node_modules or not?

1 Like

Hello, @SWP360
Yes, via console.

1 Like

What’s the path for it?

Uff, /node_modules? :smile:

Hey @SWP360 the absolute path would be /app/node_modules, which generally is a link to a directory on a shared device. You can access the files there, but changes to those files won’t be permanent; they’ll be overridden the next time your project restarts.

What is it that you’re trying to accomplish? We might be able to give better guidance if we understood your goals a little better.

1 Like

I wanna start my app through a dependency if that makes sense

I’m probably just missing the idea here; can you provide any more specific information to help me understand it better?

I wanna start my app in nodemon through package.json if that’s possible

Your app has already built-in auto-update feature from Glitch. Every time you edit your app files, node project restarts automatically. If you want to configure restart delay, you can add watch.json file with this structure:

{
  "install": {
    "include": [
      "^package\\.json$",
      "^\\.env$"
    ]
  },
  "restart": {
    "exclude": [
    ],
    "include": [
      "\\.js$",
      "\\.json",
      "\\.sqlite"
    ]
  },
  "throttle": 10000
}

‘install’ means running pnpm install, ‘restart’ means restarting your project


MOD EDIT: minor correction

4 Likes

It appears that any edits I make to files within node_modules gets overwritten each time the project re-starts. Is there any way to have edits persist?

Hey @donna0, generally speaking editing node_modules files in Glitch isn’t “best practice”, whatever that really means. Since Glitch restarts your projects from a fresh (p)npm installation every 12 hours or so, edited files in node-modules won’t persist.

Depending on what you want to edit, you could “fork” the module you’re hoping to update in GitHub and install your fork instead of the main module. You can also script replacing the default file with your edited file after the install step but before the start step by adding a prestart script in your package.json file as described in Default Node-red flow and pnpm, but that’s a little convoluted too.

Either of those approaches (or really any approach that has you editing installed packages in your node_modules directory) means that you won’t get the most recent updates to your package, which can be risky if they patch a security hole.

Hope this helps!

4 Likes