MODULE_NOT_FOUND error
What is the likely cause of this error reflected in my partial Passenger log file below?
This results after running NPM Install from the cPanel (86.0 (build 21)) Node.js Applications Management GUI, then starting the application and visiting the URL of the deployment. cPanel is running on linux.
App 29732 output: internal/modules/cjs/loader.js:775
App 29732 output: throw err;
App 29732 output: ^
App 29732 output:
App 29732 output: Error: Cannot find module 'csvtojson'
App 29732 output: Require stack:
...
App 29732 output: - /opt/passenger-5.3.7-9.el7.cloudlinux/src/helper-scripts/node-loader.js
App 29732 output: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
App 29732 output: at Function.Module._load (internal/modules/cjs/loader.js:677:27)
App 29732 output: at Module.require (internal/modules/cjs/loader.js:830:19)
App 29732 output: at Module.require (/opt/passenger-5.3.7-9.el7.cloudlinux/src/helper-scripts/node-loader.js:80:25)
App 29732 output: at require (internal/modules/cjs/helpers.js:68:18)
...
App 29732 output: at Module._compile (internal/modules/cjs/loader.js:936:30)
App 29732 output: at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
App 29732 output: at Module.load (internal/modules/cjs/loader.js:790:32)
App 29732 output: at Function.Module._load (internal/modules/cjs/loader.js:703:12)
App 29732 output: at Module.require (internal/modules/cjs/loader.js:830:19)
App 29732 output: at Module.require (/opt/passenger-5.3.7-9.el7.cloudlinux/src/helper-scripts/node-loader.js:80:25)
App 29732 output: at require (internal/modules/cjs/helpers.js:68:18)
...
App 29732 output: at Module._compile (internal/modules/cjs/loader.js:936:30)
App 29732 output: at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10) {
code: 'MODULE_NOT_FOUND',-
Issue resolved. This npm package was mistakenly installed as a dev dependency. Moving it to regular dependencies resolved the errors. 0 -
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 -
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 -
@jairosv - did you check the npm package as the server as reported by the previous user? 0 -
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 -
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 -
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 -
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 all0 -
I'm glad you were able to get that resolved! 0
Please sign in to leave a comment.
Comments
10 comments