Home > OS >  How to handle packages on production
How to handle packages on production

Time:04-09

I just started a Node.js REST API application and deploy on CPanel with the supported version of 10.24.1 of Node.js. I need to know how to avoid those annoying error logs after running npm install on production mode in order to prevent my application eventually crash (application currently is running).

error

logs

package.json

I have to say that this is my very first project that I upload to production, so I created a simple 'Hello world' app to test. Thanks in advance.

CodePudding user response:

Before running your server, you need to ensure that all the dependencies are installed properly. The error clearly says it can't find the express module. Did you run the npm install command before starting up your server?

CodePudding user response:

Once you deploy on a new server, you need to install dependencies before running your script.

So, on new deployed server, do:

npm install

before running your script.

It is the same if you update your project and have adding or updating new packages, run npm install again.

Your installed module goes in node_modules directory at the root of project directory.

  • Related