Skip to main content

MODULE_NOT_FOUND error

Comments

10 comments

  • drmartell
    Issue resolved. This npm package was mistakenly installed as a dev dependency. Moving it to regular dependencies resolved the errors.
    0
  • SamuelM
    Hello @drmartell Thank you for getting back to us to confirm that you resolved the issue. I'm glad to hear that. I'll go ahead and mark this thread as Solved. Best regards
    0
  • jairosv
    Hi my error this is MODULE_NOT_FOUND: internal/modules/cjs/loader.js:883 throw err; ^ Error: Cannot find module './home/modajemadmin/server/controllers/authControllers.js' Require stack: - /home/modajemadmin/server/routes/authRoutes.js - /home/modajemadmin/server/index.js - /usr/local/lsws/fcgi-bin/lsnode.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725:27) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at Object. (/home/modajemadmin/server/routes/authRoutes.js:5:26) at Module._compile (internal/modules/cjs/loader.js:1063:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) at Module.load (internal/modules/cjs/loader.js:928:32) at Function.Module._load (internal/modules/cjs/loader.js:769:14) at Module.require (internal/modules/cjs/loader.js:952:19) { code: 'MODULE_NOT_FOUND', requireStack: [ '/home/modajemadmin/server/routes/authRoutes.js', '/home/modajemadmin/server/index.js', '/usr/local/lsws/fcgi-bin/lsnode.js' ] }
    0
  • cPRex Jurassic Moderator
    @jairosv - did you check the npm package as the server as reported by the previous user?
    0
  • jairosv
    They are their own files, not installation packages, these are to connect to the mysql database, they tell me that they are not recognized. I think the error is different
    0
  • cPRex Jurassic Moderator
    Can you let me know what process you've used to set that up and how you get the error? Our support for Node.JS is limited, as outlined here:
    0
  • jairosv
    Shure, I am making a server in react loap the folder and files the folder configuration node js. I am attaching my file index.js [CODE=javascript]require('dotenv').config({path: 'variables.env'}); const express = require('express'); const cors = require('cors'); const morgan = require('morgan'); const fs = require('fs'); const path = require('path') const formidable = require('formidable'); const dotenv = require("dotenv"); dotenv.config(); //Crear el servidor const app = express(); app.use(morgan('dev')); app.use(cors()); app.use(express.json()); //habilitar cors app.use(cors()); //Habilitar express.json app.use(express.json({extended: false})); const PORT = process.env.PORT || 4000; //Importar rutas app.use('/api/auth',require('./routes/authRoutes')); /*app.use('/api/procesos',require('./routes/invarticulosRoutes')); app.use('/api/invmante',require('./routes/invdepartamentosRoutes')); app.use('/api/invmante',require('./routes/marcasRoutes')); app.use('/api/invmante',require('./routes/invtallasRoutes')); app.use('/api/invmante',require('./routes/invdettallaRoutes')); */ //Carga de archivos app.post('/api/upload', (req, res, next) => { //console.log(req); const form = new formidable.IncomingForm(); form.parse(req, function(err, fields, files){ console.log(files); const oldPath = files.profilePic.path; const newPath = path.join(__dirname, 'public/productos') + '/'+Date.now()+files.profilePic.name; console.log(oldPath); const rawData = fs.readFileSync(oldPath) fs.writeFile(newPath, rawData, function(err){ if(err){ console.log(err); return res.send(err); }else{ console.log(newPath); return res.send({ success:"Success", newPath :newPath }); } }); }); }); //arrancar la app app.listen(PORT, () => { console.log(`El servidor esta funcionando en el puerto ${PORT}`); });
    Attaching picture from my server.
    0
  • cPRex Jurassic Moderator
    While I certainly don't claim to be a Node.JS expert, I don't see anything out of the ordinary there. it might be best to submit a ticket to our team so we can check that on the server directly for you. If you do decide to submit a ticket, please post the number here so I can follow along and keep the community udpated.
    0
  • jairosv
    Hi, I solved the problem, this happened since Linux is case sensitive and windows do not in the folders I corrected the file and ready I attached an example const articulosControllers = require('../controllers/articulosControllers');-- incorrect const articulosControllers = require('../Controllers/articulosControllers'); -- correct
    Thank you very much to all
    0
  • cPRex Jurassic Moderator
    I'm glad you were able to get that resolved!
    0

Please sign in to leave a comment.