src.js:
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
I made this for my website, i want this file to run forever, but when i try to install pm2 by npm i pm2 -g
it throws this error:
npm ERR! code ENOENT
npm ERR! syscall mkdir
npm ERR! path /usr/lib/node_modules/pm2
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, mkdir /usr/lib/node_modules/pm2
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
how to fix it?
and my second question if i run it with node src.js it listens on mywebdomain:3000, i want it to listen on mywebdomain/. how do i do that?