Skip to content

NPM package broken on Windows #34

airportyh opened this Issue Dec 28, 2011 · 8 comments

2 participants


On Windows, for some reason after installing the module, some required files aren't present, in particular js-yaml.js and lib/js-yaml.js, which cause the library to not work at all.

Nodeca member
puzrin commented Dec 28, 2011

That's not js-yaml issue.

@puzrin puzrin closed this Dec 28, 2011

Any ideas where to look? I guess probably npm? I'd like to get to the bottom of this so users can use your module on Windows. In any case, I'll dig into it if you are not willing.

Nodeca member
puzrin commented Dec 28, 2011

No ideas. We have no practical needs to investigate situation with windows platform & browsers. If you like to spend time for it - pull requests will be accepted.


The problem is that the files were ignored by the listing in .npmignore, see here npm/npm#1967. I have verified that removing those lines:


does fix the problem on Windows. I don't know the reason for ignoring those files in the first place, but the problem is that, by virtue of those lines being there, lib/js-yaml.js gets skipped - which I am not sure if is a bug or if so whose bug it is. Anyway, does that (removing the two lines)seem like the right fix? Or do you have an idea of a better fix?


Nodeca member
puzrin commented Dec 31, 2011

Those are browserified versions for BROWSER. They can't make problem in npm package. Something is wrong in your code.

  1. Make sure, that your problem is really win-specific. I mean, that right phrase should be like "This code work in linux, but fails in win".
  2. Provide code examples.

Okay you got it.

Results on Mac

airportyhs-MacBook-Air:testem airportyh$ sudo npm install js-yaml
js-yaml@0.3.1 ./node_modules/js-yaml 
airportyhs-MacBook-Air:testem airportyh$ node
> require('js-yaml')
{ scan: [Function: scan],
  compose: [Function: compose],
  load: [Function: load],
  loadAll: [Function: loadAll],
  safeLoad: [Function: load],
  safeLoadAll: [Function: loadAll],
  addConstructor: [Function: addConstructor] }

Worked great. Now on Windows

C:\Users\airportyh\testem>npm install js-yaml
npm http GET
npm http 304
js-yaml@0.3.1 ./node_modules/js-yaml

> require('js-yaml')
Error: Cannot find module './lib/js-yaml.js'
    at Function._resolveFilename (module.js:334:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:357:17)
    at require (module.js:368:17)
    at Object.<anonymous> (C:\Users\airportyh\testem\node_modules\js-yaml\index.
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Module.require (module.js:357:17)

So, on Windows it can't find the file ./lib/js-yaml.js and I verified that it is indeed not there

C:\Users\airportyh\testem>dir node_modules\js-yaml\lib
 Volume in drive C has no label.
 Volume Serial Number is 14EC-C85F

 Directory of C:\Users\airportyh\testem\node_modules\js-yaml\lib

12/31/2011  10:11 PM    <DIR>          .
12/31/2011  10:11 PM    <DIR>          ..
12/31/2011  10:11 PM    <DIR>          js-yaml
               0 File(s)              0 bytes
               3 Dir(s)   1,539,788,800 bytes free

If I remove the line /js-yaml.js from .npmignore in js-yaml, it fixes the problem. I think this is a bug in npm though, as I don't think listing /js-yaml.js should ignore /lib/js-yaml.js. So, I've added a new comment on the npm issue npm/npm#1967

Oh! And happy new year!

Nodeca member
puzrin commented Jan 1, 2012

Yes, seems ./lib/js-yaml.js is missed on win. It's better to send all this details to npm issue tracker. Don't try to use browserified versions, result will be unpredictable. And another bug is in node, that require includes ./js-yaml.js instead of ./lib/js-yaml.js.

PS. Personally, on windows i advice you to install virtualbox, and run ubuntu linux in it. That will solve another problem, that most C modules will not work on win now.


Okay. Isaac agreed it was a bug in npm, but which will not be fixed immediately(npm/npm#1967 (comment)). He suggested a workaround which I have implemented(#35) and tested on Windows and regression tested on OSX. Cheers!

Regarding your comment about VirtualBox. I am working on this not because of personal use(I use Mac), but that I want my tool - which will depend on your package - to be usable across platforms.

@oneputin oneputin pushed a commit to oneputin/js-yaml that referenced this issue Feb 3, 2016
@airportyh airportyh Added an override in .npmignore to not ignore lib/js-yaml.js as a wor…
…karound to

a bug in npm. See nodeca/js-yaml#34 and npm/npm#1967.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.