Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module (nodejs)

Tags:

node.js

Module: getmac https://www.npmjs.org/package/getmac

Backstory: I was using module getmac before and it worked like a charm. Some time ago I updated nodejs to 0.11. And today I tried to use it again. I installed it (npm install get mac) Tried it to use. Nope. "Cannot find module". I see getmac folder in node_modules. Npm ls shows:

├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected]

I am using like 20+ other modules without any problems.

OS: Windows 7 32bit, administrator account

How I test if it work: Of possibility that my project can be the issue:

  1. I created new folder.
  2. Then I open command line and use: npm install getmac
  3. I created test.js with one line: require('getmac');
  4. In command line: nodejs test.js
  5. Every time result is the same:

    module.js:340
        throw err;
              ^
    Error: Cannot find module 'getmac'
        at Function.Module._resolveFilename (module.js:338:15)
        at Function.Module._load (module.js:280:25)
        at Module.require (module.js:364:17)
        at require (module.js:380:17)
        at Object.<anonymous> (C:\Users\Nfq\testo\test.js:1:63)
        at Module._compile (module.js:456:26)
        at Object.Module._extensions..js (module.js:474:10)
        at Module.load (module.js:356:32)
        at Function.Module._load (module.js:312:12)
        at Function.Module.runMain (module.js:497:10)
    
  6. Others modules works fine

What I tried:

  • npm install getmac (no errors occurred)
  • npm remove/uninstall getmac and install it again
  • npm -g install getmac
  • require('./node_modules/getmac')
  • install from manually downloaded module with different versions 1.04/1.0.5/1.0.6
  • node 0.11.13/0.10.32/0.10.25/0.8.27/
  • install it in program files/nodejs/node_modules
  • delete files in %appdata%/npm/
  • delete files in program files/nodejs/node_modules
  • reboot computer several times
  • at virtual machine it works
  • CLI

error from sublimetext2:

[8036:1014/141615:INFO:CONSOLE(293)] "{"stack":"Error: Cannot find module 'getmac'\n at Function.Module._resolveFilename (module.js:334:15)\n 
"Uncaught Error: Cannot find module 'getmac'", source: module.js (336)

File structure of folder node_modules/getmac:

   C:\Users\Nfq\testo\node_modules\getmac
    -   .npmignore
    -   History.md
    -   LICENSE.md
    -   package.json
    -   README.md
    -
    +¦¦¦bin
    -       getmac-node
    -
    L¦¦¦node_modules
        L¦¦¦extract-opts
            -   .npmignore
            -   example.js
            -   LICENSE.md
            -   package.json
            -   README.md
            -
            +¦¦¦node_modules
            -   L¦¦¦typechecker
            -       -   .npmignore
            -       -   cyclic.js
            -       -   History.md
            -       -   LICENSE.md
            -       -   package.json
            -       -   README.md
            -       -
            -       L¦¦¦out
            -           L¦¦¦lib
            -                   typechecker.js
            -
            L¦¦¦out
                L¦¦¦lib
                        extract-opts.js

Please help me.

like image 586
Verh Avatar asked May 16 '26 01:05

Verh


1 Answers

Remove the node_modules folder, run npm cache clean then reinstall the packages npm install.

like image 112
Razvan Avatar answered May 17 '26 18:05

Razvan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!