Node Modules not being detected in node.js app
Hello, I have a Cpanel shared hosting on Namecheap.
I have created two Node js apps with completely different methods. Both don't work.
It works on my local device. The app is an express application. I made the application on my local machine by running
This creates a folder called api with the stuff for the express node app. I then simply went to Cpanel and clicked on Setup node.js app. Then I created an app simply called api with root domain as mywebsite.com/api Then I uploaded all the files except node_modules folder from my local machine to the api folder in the root directory of the cpanel (Not the one in public_html) then I clicked on "run npm install" in the setup node.js app panel. This created a new node_modules folder on the cpanel. When I run the app through www.mywebsite.com/api I get an error in the logs where it can't find the module for anything. The node_modules folder is there. You can see it in screenshot 1. I then tried to just upload the node_modules folder along with the files. So I created a new app with directory mywebsite.com/nodeapi . Tried it and it still gives same error of not being able to find modules.
npx express-generator api
This creates a folder called api with the stuff for the express node app. I then simply went to Cpanel and clicked on Setup node.js app. Then I created an app simply called api with root domain as mywebsite.com/api Then I uploaded all the files except node_modules folder from my local machine to the api folder in the root directory of the cpanel (Not the one in public_html) then I clicked on "run npm install" in the setup node.js app panel. This created a new node_modules folder on the cpanel. When I run the app through www.mywebsite.com/api I get an error in the logs where it can't find the module for anything. The node_modules folder is there. You can see it in screenshot 1. I then tried to just upload the node_modules folder along with the files. So I created a new app with directory mywebsite.com/nodeapi . Tried it and it still gives same error of not being able to find modules.
Please sign in to leave a comment.
Comments
0 comments