Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

933
Vistas
Running npm start on pm2 server returns Error: Cannot find module Cors

When I run npm start or even pm2 start npm --name "app name" -- start command, my app returns an error like this:

/home/cloud/sites/myapp$ npm start 

> myapp@1.0.0 start /home/cloud/sites/myapp
> node server.js

internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module 'Cors'
Require stack:
- /home/cloud/sites/myapp/server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/cloud/sites/myapp/server.js:2:14)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/cloud/sites/myapp/server.js' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp@1.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the myapp@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-05-12T07_31_36_119Z-debug.log

This is my package.json:

{
  "name": "myapp",
  "version": "1.0.0",
  "description": "* TEST\r * Login validation",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server.js"
  },
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "crypto-random-string": "^3.3.1",
    "express": "^4.17.1",
    "is-empty": "^1.2.0",
    "jsonwebtoken": "^8.5.1",
    "mongoose": "^5.11.17",
    "socket.io": "^4.0.1",
    "validator": "^13.5.2"
  }
}

And my directory tree:

-myapp
 -config
 -node_modules
 -routes
 -utils
 -validation
 -package.json
 -package-lock.json
 -server.js

I've tried deleting package-lock.json and node_modules and then run npm install again, even tried npm install cors, it always installs fine but the error stays the same. Any ideas?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Replace it

const cors = require('Cors')

With this

const cors = require('cors')
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda