Cannot find module 'express' pm2

at Function.Module._load (module.js:498:3)
1|[LS][Pro | Error: Cannot find module ‘express’
1|[LS][Pro | at Function.Module._resolveFilename (module.js:548:15)
1|[LS][Pro | at Function.Module._load (module.js:475:25)
1|[LS][Pro | at Module.require (module.js:597:17)
1|[LS][Pro | at require (internal/module.js:11:18)
1|[LS][Pro | at Object. (/var/www/lscomputer_production/api/administrator/server.js:3:17)
1|[LS][Pro | at Module._compile (module.js:653:30)
1|[LS][Pro | at Object.Module._extensions…js (module.js:664:10)
1|[LS][Pro | at Module.load (module.js:566:32)
1|[LS][Pro | at tryModuleLoad (module.js:506:12)
1|[LS][Pro | at Function.Module._load (module.js:498:3)

Sometime i get above error, but i didn’t know how to stop it, when i reload app, error will fix, but i will get it again after some days working.
I had read old topic but it can not help me, so i create new topic. hope to help, thanks
This is package.json.
{
“name”: “lscomputer-api”,
“version”: “1.0.0”,
“description”: “A RESTful API built with Express to manage a lscomputer”,
“author”: “Long Pham”,
“homepage”: “”,
“repository”: {
“type”: “git”,
“url”: “”
},
“main”: “Server.js”,
“scripts”: {
“start”: “node server.js”,
“test”: “mocha --timeout 10000”,
“apidoc”: “apidoc -i documents/ -o documents/_html/ -t documents/template”
},
“license”: “MIT”,
“private”: true,
“dependencies”: {
“async”: “^2.5.0”,
“body-parser”: “^1.17.2”,
“cli-table”: “^0.3.1”,
“dustjs-linkedin”: “^2.4.0”,
“ejs”: “^2.5.7”,
“email-templates”: “^2.7.1”,
“express”: “^4.15.4”,
“express-routes-versioning”: “^0.3.0”,
“express-validator”: “^3.2.1”,
“fs”: “0.0.1-security”,
“handlebars”: “^4.0.0”,
“hl-util”: “file:…/…/_library/hl-util”,
“jade”: “^1.3.1”,
“jsonfile”: “^3.0.1”,
“jsonwebtoken”: “^7.4.3”,
“less”: “^2.5.0”,
“lodash”: “^4.0.1”,
“morgan”: “^1.8.2”,
“mysql”: “^2.14.1”,
“node-gyp”: “^3.8.0”,
“node-sass”: “^3.1.1”,
“node-uuid”: “latest”,
“nodemailer”: “^4.0.1”,
“nunjucks”: “^1.3.4”,
“path”: “^0.12.7”,
“request”: “^2.72.0”,
“styl”: “^0.2.7”,
“stylus”: “^0.53.0”
},
“devDependencies”: {
“chai”: “^3.5.0”,
“chai-http”: “^2.0.1”,
“mocha”: “^2.4.5”
}
}

Hi @xuanlv0703 – welcome to the Glitch forum! Could you share your project name (if it’s public?) This is just a shot in the dark, but when you look at the package.json in the editor, do you see any warnings for syntax errors? That’s what has caused that kind of error for me in the past.
If you’re only seeing the error sometimes (without any changes in your code) that might be because the project is running low on space, I think? If you look under Tools -> Container Status do you see anything?

hi @househaunt i don’t see warning syntax error
Filesystem Size Used Avail Use% Mounted on
/dev/ploop23050p1 599G 271G 299G 48% /
none 8.0G 4.0K 8.0G 1% /dev
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 1.7G 648K 1.6G 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 8.0G 0 8.0G 0% /run/shm
none 100M 0 100M 0% /run/user
total 617G 271G 316G 47% -

I use pm2 to manager nodejs application.

1 Like

I used to experience this aswell, I found out that remixing the project while it isn’t throwing that error and running pnpm install in console should fix it

1 Like

hi @SpeedyCraftah i use npm, but project is working, so after sometime it’s appear above error, so it’s mean npm install had run before.

Glitch uses pnpm by default, which means you should really use pnpm instead of npm