npm2nix icon indicating copy to clipboard operation
npm2nix copied to clipboard

generated file is incomplete

Open AladdiX opened this issue 10 years ago • 16 comments

I'm running npm2nix on my package.json and it finishes without errors, but I'm getting a file that looks like this :

{ self, fetchurl, fetchgit ? null, lib }:

{

I have node v0.12.2 and npm2nix 5.8.1 installed.

AladdiX avatar Apr 27 '15 11:04 AladdiX

@AladdiX I saw this same behavior... It turned out it was a typo for me, I had Latest rather than latest. This at least fixed it for me. I'm brand new to the program, so I'm not sure that's going to help in your case... but it has to be worth a shot...

jamesthompson avatar May 07 '15 02:05 jamesthompson

I have the same problem with the package.json from popcorntime.

This is with npm2nix 5.12.0 from nixpkgs.

bobvanderlinden avatar Jun 07 '15 17:06 bobvanderlinden

Yes, thats probably because of the changes in npm format, which now supports something like github:owner/repo and similar ways to specifiy git/github repos. I will have to fix npm2nix soon, because we also depend on it. And yeah, everytime npm2nix fails, it generates only header, so there is some other error, besides the empty file.

Too bad i have to fix it every few months(but it's the only thing we have and code is a bit of mess, and yeah coffescript), we will have to figure out simpler and more solid solution for new npm2nix, any ideas?

offlinehacker avatar Jun 07 '15 17:06 offlinehacker

Hmm, one problem I found was that optjs has a version that is incompatible with the latest semver (3.2.1-boom, notice the -boom. 3.2.1-boom doesn't satisfy the * spec), sigh. The semver version used by the stable npm version works alright, the version used by npm2nix at the moment does not. Should I do a PR to downgrade semver to the right version (~4.2.0 vs ~4.3.0)?

The generated nix file is still not complete though, I'll investigate further.

I see how you'd have to fix things every few months. This really is quite annoying. If npm had some kind of library that handles most of what you're doing in npm2nix, that might be better. Though, from what I've found they don't.

bobvanderlinden avatar Jun 07 '15 19:06 bobvanderlinden

Yeah, i think it should be save to downgrade semver if it fixes the problem. We still need to find better solution for npm2nix. Is there any nice way we could get dependencies after doing "npm install"?

On Sun, Jun 7, 2015 at 9:20 PM Bob van der Linden [email protected] wrote:

Hmm, one problem I found was that optjs has a version that is incompatible with the latest semver (3.2.1-boom, notice the -boom. 3.2.1-boom doesn't satisfy the * spec), sigh. The semver version used by the stable npm version works alright, the version used by npm2nix at the moment does not. Should I do a PR to downgrade semver to the right version ( ~4.2.0 vs ~4.3.0)?

The generated nix file is still not complete though, I'll investigate further.

I see how you'd have to fix things every few months. This really is quite annoying. If npm had some kind of library that handles most of what you're doing in npm2nix, that might be better. Though, from what I've found they don't.

— Reply to this email directly or view it on GitHub https://github.com/NixOS/npm2nix/issues/21#issuecomment-109789782.

offlinehacker avatar Jun 07 '15 21:06 offlinehacker

I've submitted #24, which solved the problem of a incomplete output for me. It should also give a better indication why the file isn't complete yet (if this is still a problem), because one of the packages is stuck fetching the necessairy data. With the PR it'll show which packages still seem to be fetching at that time.

bobvanderlinden avatar Jun 07 '15 21:06 bobvanderlinden

@offlinehacker npm ls shows all installed dependencies in node_modules, each with their version number. This could be of use. Not sure if parsing npm ls is the right way or whether we could use npm's code to get the same information in a better format.

bobvanderlinden avatar Jun 07 '15 21:06 bobvanderlinden

It might be sane to add a feature to "npm ls" to output json, this solves a part of the problem, the other part is fetching dependencies, but this is clearly more simple problem. I will check if there are any other issues with taking this approach and write a tool.

On Sun, Jun 7, 2015 at 11:35 PM Bob van der Linden [email protected] wrote:

@offlinehacker https://github.com/offlinehacker npm ls shows all installed dependencies in node_modules, each with their version number. This could be of use. Not sure if parsing npm ls is the right way or whether we could use npm's code to get the same information in a better format.

— Reply to this email directly or view it on GitHub https://github.com/NixOS/npm2nix/issues/21#issuecomment-109801752.

offlinehacker avatar Jun 07 '15 21:06 offlinehacker

"npm ls" outputs all packages in a recursive tree. You do see the dependencies that way.

What is still missing is the hashes for the targz files. It would be nice if npm could download only the targz files, so that npm2nix can hash them. Not sure what a good approach would be for this though. Maybe those files are available in some cache?

EDIT: Having it in JSON would be a nice approach I think. Found it: npm ls --json

bobvanderlinden avatar Jun 07 '15 21:06 bobvanderlinden

And hashes for git repos i guess too...

On Sun, Jun 7, 2015 at 11:47 PM Bob van der Linden [email protected] wrote:

"npm ls" outputs all packages in a recursive tree. You do see the dependencies that way.

What is still missing is the hashes for the targz files. It would be nice if npm could download only the targz files, so that npm2nix can hash them. Not sure what a good approach would be for this though. Maybe those files are available in some cache?

— Reply to this email directly or view it on GitHub https://github.com/NixOS/npm2nix/issues/21#issuecomment-109802330.

offlinehacker avatar Jun 07 '15 21:06 offlinehacker

Oh right, I forgot about those. Since git repos as dependencies aren't the norm it doesn't matter much to retrieve them seperately.

As for targz files: here is the cache: ~/.npm/log-symbols/1.0.2/package.tgz

bobvanderlinden avatar Jun 07 '15 21:06 bobvanderlinden

I've created #25 so that we can focus on reusing npm there. I hope this issue is solved with #24.

bobvanderlinden avatar Jun 07 '15 22:06 bobvanderlinden

I'm really looking forward to #25, sounds like the right way to do things! In the mean time, is there a way to get the error from npm2nix so we know where to dig?

wmertens avatar Aug 15 '15 12:08 wmertens

Any news? Nodejs is rather unusable without npm2nix. The latest nixos unstable as of nixos/nixpkgs@1357692 still has this issue.

lucabrunox avatar Aug 20 '15 19:08 lucabrunox

We have to make a new implementation, current one is broken by design and by code. I will not have time before next weekend, but i need this too, so i will make an attempt then if noone else will do it before.

On Thu, Aug 20, 2015 at 9:31 PM lethalman [email protected] wrote:

Any news? Node packages are rather unusable without npm2nix. The latest nixos unstable as of 1357692 still has this issue.

— Reply to this email directly or view it on GitHub https://github.com/NixOS/npm2nix/issues/21#issuecomment-133142349.

offlinehacker avatar Aug 20 '15 19:08 offlinehacker

@offlinehacker What about the shrinkwrap idea? Is that a viable solution or is it something to avoid?

bobvanderlinden avatar Aug 20 '15 21:08 bobvanderlinden