Ask coding questions

← Back to all posts
How to make NPM Package auto-generate folders and files?
pixelphant (0)

I've used other IDEs before and there when I install an NPM package, it automatically creates many files and folder with names like “node_modules”, “.npm”, “.config”, etc.
But when I install it in a Node.js Repl, it doesn't create any file or folder except “database”, and “package-lock.json” (I created package.json tho)
Anyone have a fix of it?

Comments
hotnewtop
SixBeeps (5629)

As OldWizard209 mentioned, the node_modules folder as well as the other config files are kept in the background as to not clutter the files pane. If you absolutely need direct access to these for whatever reason (i.e. if you know what you're doing), you could try switching to Nix.

SixBeeps (5629)

@pixelphant Nix is an experimental environment on Replit that grants access to a neat little package manager.

Here's a short video explaining exactly what it is and how to use it.

OldWizard209 (1702)

When you initiate npm in the replit shell, replit automatically makes a package.json file. But if you install a package, replit makes a package-lock.json file. However, in the package.json file, you can see the package name in the dependencies key. For example, I installed the express module, so my package.json is like this:

Notice the express in the end. The node_modules file that is created for you locally on your PC, is done by replit in the background. That is why replit is an amazing tool to use.

You don't need a node_modules file is not required for you to use the npm packages. In fact, you don't even need to initialize npm. If you just run the code with the require('package) statements, replit will install the packages itself.

pixelphant (0)

@OldWizard209 I wanna edit node_modules codes

OldWizard209 (1702)

well i guess you will have to do that manually on you local computer. or just initialize npm on your pc and upload the files onto replit? @pixelphant