Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Jesse Thompson10,684 Points
Where should the node_modules & package folder be when uploading an app to a server to be hosted live?
In this tutorial I ended up installing all the stuff at C:\Users\Me but the app file I created is at C:\Users\Me\Downloads\nodejslearn\npmbasics\app.js.
If npmbasics was an app to be uploaded I would have to install everything locally at C:\Users\Me\Downloads\nodejslearn\npmbasics\app.js for it to work with all the dependencies when I upload? So node_modules & package folder there locally?
This looks like Windows and I'm not a Windows guy anymore, but I think the simple answer is node_modules does not get loaded up to a production server and package.json should be in the root of your project.
The reason for this is that node_modules is both dynamic and specific to the environment. When "npm install" is executed in the root of of the app on the production server, your package.json informs npm to create a new node_modules folder (in the root of the app) and the "dependencies" object within package.json informs npm which specific modules and versions to deploy.
I know that heroku (at least in a Mac environment) requires an engines object that looks like this
that signals npm which version of node to use. Of course that 9.8.0 will be dependent on which version of node you are running on the localhost.
Now, I have just exceeded my knowledge, so I will stop for now. I hope that helps. But be sure you confirm it with a Windows guy.