New World

[React.JS] Express 서버 개발환경 구축 중 code: 'MODULE_NOT_FOUND' 로 계속 에러 본문

Programming/Bug Zero

[React.JS] Express 서버 개발환경 구축 중 code: 'MODULE_NOT_FOUND' 로 계속 에러

hyeovi 2021. 4. 17. 19:36
728x90
반응형

 

 

위 와 같은 에러가 발생했을 때 해결하는 방법

package-lock.json 파일과 node_modules 폴더를 먼저 삭제하고 npm install을 콘솔창에 입력하면 된다.

 

이것 때문에 한참 고민했었는데 방법은 간단했다.

나는 서버와  Express 서버 개발환경 구축하면서, 그리고 구축해서 에러가 발생해서 --save-dev로 설치했을 때 발생한 현상이지만 또 언젠가 이와 같은 에러를 만나게 되면 저 해결 방안으로 해결할 수 있길.. 제발..

 

더보기

 PS D:\Program\dev\Portfolio\management> npm run start Debugger attached. > management@0.0.0 start D:\Program\dev\Portfolio\management > node ./bin/www Debugger attached. Waiting for the debugger to disconnect... internal/modules/cjs/loader.js:883 throw err; ^ Error: Cannot find module 'D:\Program\dev\Portfolio\management\bin\www' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] } npm ERR! code ELIFECYCLE npm ERR! management@0.0.0 start: `node ./bin/www` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the management@0.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! C:\Users\UsersName\AppData\Roaming\npm-cache\_logs\2021-04-17T10_17_37_666Z-debug.log Waiting for the debugger to disconnect... PS D:\Program\dev\Portfolio\management> npm run start Debugger attached. > management@1.0.0 start D:\Program\dev\Portfolio\management > node server.js Debugger attached. Waiting for the debugger to disconnect... internal/modules/cjs/loader.js:883 throw err; ^ Error: Cannot find module 'express' Require stack: - D:\Program\dev\Portfolio\management\server.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. (D:\Program\dev\Portfolio\management\server.js:1:17) 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 Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) { code: 'MODULE_NOT_FOUND', requireStack: [ 'D:\\Program\\dev\\Portfolio\\management\\server.js' ] } npm ERR! code ELIFECYCLE npm ERR! management@1.0.0 start: `node server.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the management@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! C:\Users\UsersName\AppData\Roaming\npm-cache\_logs\2021-04-17T10_21_02_380Z-debug.log Waiting for the debugger to disconnect... PS D:\Program\dev\Portfolio\management> npm install Debugger attached. npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN management@1.0.0 No repository field. npm WARN management@1.0.0 No license field. added 109 packages from 91 contributors and audited 109 packages in 11.421s 8 packages are looking for funding run `npm fund` for details found 0 vulnerabilities

반응형
Comments