3

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:

├─┬ getmac@1.0.6
│ └─┬ extract-opts@2.2.0
│   └── typechecker@2.0.8

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.

Verh
  • 71
  • 1
  • 8
  • 1
    Have you checked if it works from the CLI? – Razvan Oct 14 '14 at 15:41
  • try this `sudo npm install getmac -g` – mkoryak Oct 14 '14 at 16:12
  • 1
    @mkoryak `sudo` doesn't work on windows – Rahil Wazir Oct 14 '14 at 16:15
  • @razvan I am at administrator account – Verh Oct 14 '14 at 16:16
  • 1
    @mkoryak Also note that globally installed packages aren't available to `require()` [by design](https://www.npmjs.org/doc/files/npm-folders.html). – Jonathan Lonowski Oct 14 '14 at 16:23
  • @JonathanLonowski After global install I was trying with `getMac(function(err,macAddress){ if (err) throw err; console.log(macAddress); });` thats proper? – Verh Oct 14 '14 at 16:28
  • I found some related questions. They seem to be talking about a environment variable specific to Windows. Might be a lead : [first](http://stackoverflow.com/questions/9587665/nodejs-cannot-find-installed-module-on-windows) and [second](http://stackoverflow.com/questions/25647276/cannot-find-module-connect-on-windows-7) – Razvan Oct 14 '14 at 19:36
  • @razvan **thank you so much**, **`npm cache clean`** did the job! Thank you man. – Verh Oct 14 '14 at 20:14
  • Then I'll add it as an answer. Maybe it will be helpful. – Razvan Oct 14 '14 at 21:14

1 Answers1

4

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

Razvan
  • 3,017
  • 1
  • 26
  • 35