Home > Enterprise >  ERR_MODULE_NOT_FOUND
ERR_MODULE_NOT_FOUND

Time:08-12

please help me, iam a newbie so i dont know to fix it

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\nghia\OneDrive\Máy tính\nodebasic\src\configs\viewEngine' imported from C:\Users\nghia\OneDrive\Máy tính\nodebasic\src\server.js
    at new NodeError (internal/errors.js:322:7)
    at finalizeResolution (internal/modules/esm/resolve.js:318:11)
    at moduleResolve (internal/modules/esm/resolve.js:776:10)
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:887:11)
    at Loader.resolve (internal/modules/esm/loader.js:89:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:76:40)
    at link (internal/modules/esm/module_job.js:75:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

my package.json file: enter image description here

and this is sever.js: enter image description here

CodePudding user response:

import, by default, looks from files with the .mjs extension. In order to import a .js file, you need to explicitly state its extension:

import configViewEngine from './configs/viewEngine.js'
  • Related