Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node:internal/modules/cjs/loader:1247 throw err; ^ #4538

Open
2 tasks done
BM-ACADEMY opened this issue Jan 24, 2025 · 2 comments
Open
2 tasks done

node:internal/modules/cjs/loader:1247 throw err; ^ #4538

BM-ACADEMY opened this issue Jan 24, 2025 · 2 comments
Labels

Comments

@BM-ACADEMY
Copy link

Node.js Version

v22.13.1

NPM Version

v10.9.2

Operating System

ubuntu

Subsystem

console

Description

show this error vps hosting mern stack app

Minimal Reproduction

Error: Cannot find module '../Models/QuoteModel'
Require stack:

  • /var/www/Travelers-Need/backend/Controller/quoteController.js
  • /var/www/Travelers-Need/backend/Routes/quoteRoutes.js
  • /var/www/Travelers-Need/backend/index.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1244:15)
    at Function._load (node:internal/modules/cjs/loader:1070:27)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1335:12)
    at require (node:internal/modules/helpers:136:16)
    at Object. (/var/www/Travelers-Need/backend/Controller/quoteController.js:1:15)
    at Module._compile (node:internal/modules/cjs/loader:1562:14)
    at Object..js (node:internal/modules/cjs/loader:1699:10)
    at Module.load (node:internal/modules/cjs/loader:1313:32) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/var/www/Travelers-Need/backend/Controller/quoteController.js',
    '/var/www/Travelers-Need/backend/Routes/quoteRoutes.js',
    '/var/www/Travelers-Need/backend/index.js'
    ]
    }

Node.js v22.13.1

Output

No response

Before You Submit

  • I have looked for issues that already exist before submitting this
  • My issue follows the guidelines in the README file, and follows the 'How to ask a good question' guide at https://stackoverflow.com/help/how-to-ask
@BM-ACADEMY
Copy link
Author

while move producntion showing this error

@AhegaoTime
Copy link

AhegaoTime commented Jan 31, 2025

you might have a sort of plugin that auto adds .js or json extension thats what happened to me

from this error:

 node:internal/modules/cjs/loader:1247
  throw err;
  ^

Error: Cannot find module './src/config/config.js'
Require stack:
- D:\HumbleLink\HumbleLink-backend\HumbleLink-backend\src\middlewares\error.js
- D:\HumbleLink\HumbleLink-backend\HumbleLink-backend\src\app.js
- D:\HumbleLink\HumbleLink-backend\HumbleLink-backend\src\index.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1244:15)
    at Function._load (node:internal/modules/cjs/loader:1070:27)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1335:12)
    at require (node:internal/modules/helpers:136:16)
    at Object.<anonymous> (D:\HumbleLink\HumbleLink-backend\HumbleLink-backend\src\middlewares\/error.js:3:1)
    at Module._compile (node:internal/modules/cjs/loader:1562:14)
    at Module._compile (D:\HumbleLink\HumbleLink-backend\HumbleLink-backend\node_modules\pirates\lib\index.js:117:24)
    at node:internal/modules/cjs/loader:1699:10
    at Object.newLoader [as .js] (D:\HumbleLink\HumbleLink-backend\HumbleLink-backend\node_modules\pirates\lib\index.js:121:7)
    at Module.load (node:internal/modules/cjs/loader:1313:32)
    at Function._load (node:internal/modules/cjs/loader:1123:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1335:12)
    at require (node:internal/modules/helpers:136:16)
    at Object.<anonymous> (D:\HumbleLink\HumbleLink-backend\HumbleLink-backend\src\/app.js:3:1)
    at Module._compile (node:internal/modules/cjs/loader:1562:14)
    at Module._compile (D:\HumbleLink\HumbleLink-backend\HumbleLink-backend\node_modules\pirates\lib\index.js:117:24)
    at node:internal/modules/cjs/loader:1699:10
    at Object.newLoader [as .js] (D:\HumbleLink\HumbleLink-backend\HumbleLink-backend\node_modules\pirates\lib\index.js:121:7)
    at Module.load (node:internal/modules/cjs/loader:1313:32)
    at Function._load (node:internal/modules/cjs/loader:1123:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1335:12)
    at require (node:internal/modules/helpers:136:16)
    at Object.<anonymous> (D:\HumbleLink\HumbleLink-backend\HumbleLink-backend\src\/index.js:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1562:14)
    at Module._compile (D:\HumbleLink\HumbleLink-backend\HumbleLink-backend\node_modules\pirates\lib\index.js:117:24)
    at node:internal/modules/cjs/loader:1699:10
    at Object.newLoader [as .js] (D:\HumbleLink\HumbleLink-backend\HumbleLink-backend\node_modules\pirates\lib\index.js:121:7)
    at Module.load (node:internal/modules/cjs/loader:1313:32)
    at Function._load (node:internal/modules/cjs/loader:1123:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Function.runMain (node:internal/modules/run_main:170:5)
    at Object.<anonymous> (D:\HumbleLink\HumbleLink-backend\HumbleLink-backend\node_modules\@babel\node\src\_babel-node.ts:159:12)
    at Module._compile (node:internal/modules/cjs/loader:1562:14)
    at Object.<anonymous> (node:internal/modules/cjs/loader:1699:10)
    at Module.load (node:internal/modules/cjs/loader:1313:32)
    at Function._load (node:internal/modules/cjs/loader:1123:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
    at node:internal/main/run_main_module:36:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'D:\\HumbleLink\\HumbleLink-backend\\HumbleLink-backend\\src\\middlewares\\error.js',
    'D:\\HumbleLink\\HumbleLink-backend\\HumbleLink-backend\\src\\app.js',
    'D:\\HumbleLink\\HumbleLink-backend\\HumbleLink-backend\\src\\index.js'
  ]
}

Node.js v22.13.1

this is the code file that i got the error from:


import httpStatus from 'http-status';
import Joi from 'joi';
import config from './src/config/config.js';
import logger from './src/config/logger.js';
import APIError from './src/utils/apiError.js';

.....more code

what i did is change the last 3 lines like this


import httpStatus from 'http-status';
import Joi from 'joi';
import config from '~/config/config';
import logger from '~/config/logger';
import APIError from '~/utils/apiError';

.....more code

from that i didnt get the error.
if it still sucks and you get the error try full pathing and adding extensions
and if it still doesnt reinstall all the node_modules by deleting the folder and then runing: npm install again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants