Home > Software design >  Error: node:internal/modules/cjs/loader:936 upon node js deploy on koyeb
Error: node:internal/modules/cjs/loader:936 upon node js deploy on koyeb

Time:10-27

I am trying to deploy a simple service Node js app on Koyeb, and i am getting an error like this :

node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module './controllers/etc...'
Require stack:
- /workspace/server.js

it looks like koyeb couldn't find the path to the server.js file... this is my package.json file :

{
  "name": "my app",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "start": "node server.js",
    "dev": "nodemon server.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "nodemon": "^2.0.20"
  },
  "dependencies": {
    "cors": "^2.8.5",
    "dotenv": "^16.0.3",
    "express": "^4.18.2",
    "mongoose": "^6.6.5"
  },
  "engines": {
    "node": "16.x"
  }
}

when i run npm start or node server.js it work fine on my local machine, the file is at the root, I also try in the scripts "start": "node ./server.js" but same issue, i scratch my head all day but i couldn't figure out what i am doing wrong... and how can i fix ? thanks

CodePudding user response:

Ok I find out later the issue is not coming from server.js path, but from the controllers... there is ONE mistake from me on one letter on the file, I couldn't find the error in local machine on windows because in Windows is case-insensitive matching... however on Koyeb and Linux i guess is case sensitive matching ! Which explain why I got this error when deploying the app because the sensitive case unmatch the file so it couldn't find the module.

  • Related