简体   繁体   中英

Hi, I get this bug here Error: Cannot find module 'debug'

Maybe I deleted something on package.json but I wrote again (I not uninstalled) I get this bug:

Error: Cannot find module 'debug'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:658:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (C:\Users\Leo\fase2\node_modules\nodemon\lib\nodemon.js:1:75)
    at Module._compile (internal/modules/cjs/loader.js:722:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
error Command failed with exit code 1.

I am lost!! what is causing the problem?

You seem to have debug module missing in your node_modules. npm install debug --save will solve the issue,also it will create an entry in package.json for the package. For further info have a look at official docs

It could be an issue with your local node_modules directory. I would recommend deleting and re-installing it fresh. Then check your local dependencies to see if debug is included again.

Before you attempt the below, make sure you are in your project folder!

To do so, delete the folder node_modules and use npm install debug to re-install. If this fails you can check the created log for any specific errors that occurred during installation.

FYI, I got this error because I moved my start.js outside of the folder that had node_modules (was separating code into two different projects).

I thought I could start the sever all the same using node ../start.js and maybe I could have with a little more debugging, but I moved all my code back into the folder tree that had my package.json and node_modules and that fixed it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM