I currently trying to deploy my nodejs project to cPanel. I have followed every steps to upload it and I am having problem when run NPM Install. I always got this error
Error
/nodevenv/myprojecttest1/20/bin/npm: line 35: /opt/alt/alt-nodejs20/root/usr/bin/npm: No such file or directory
I am not sure what wrong have I done, but here is the code for my files
app.js
const path = require('path');
const express = require('express');
const morgan = require('morgan');
const viewRouter = require('./routes/main');
const app = express();
//app.use(express.json());
app.set('view engine', 'ejs');
app.set('views', 'views');
// Static File
app.use(express.static(path.join(__dirname, 'public')));
// Middleware
app.use('/', viewRouter);
app.get('/overview', (req, res) =>{
//res.sendFile(path.join(__dirname, 'views', 'index.html'));
res.render('test3');
});
app.use((req,res) => {
const viewData = {
pageTitle: 'Page Not Found Bro'
};
res.status(404).render('404', viewData);
});
module.exports = app;
server.js
const app = require('./app');
const port = 3000;
app.listen(port, () => {
console.log(`App running on port ${port}...`);
});
server.js
{
"name": "my_project",
"version": "1.0.0",
"description": "my project",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"start": "nodemon server.js"
},
"author": "coolkid",
"license": "ISC",
"devDependencies": {
"nodemon": "^3.1.3"
},
"dependencies": {
"bootstrap": "^5.3.3",
"ejs": "^3.1.10",
"express": "^4.19.2",
"morgan": "^1.10.0"
}
}
This is how it looks like in the UI
and if I run script this error will pops out
returncode: 127
stdout:
stderr:
/nodevenv/myprojecttest1/20/bin/npm: line 37: /opt/alt/alt-nodejs20/root/usr/bin/npm: No such file or directory