Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

927
Views
Ejecutar npm start en el servidor pm2 devuelve Error: No se puede encontrar el módulo Cors

Cuando ejecuto npm start o incluso pm2 start npm --name "app name" -- start , mi aplicación devuelve un error como este:

 /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

Este es mi paquete.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" } }

Y mi árbol de directorios:

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

Intenté eliminar package-lock.json y node_modules y luego npm install nuevamente, incluso probé npm install cors , siempre se instala bien pero el error sigue siendo el mismo. ¿Algunas ideas?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Reemplázalo

 const cors = require('Cors')

Con este

 const cors = require('cors')
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!