NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.27k stars 14.25k forks source link

Parcel doesn't work #350139

Open nyarly opened 1 month ago

nyarly commented 1 month ago

Describe the bug

Trying to use nodePackages.parcel in either nix develop or nix-shell fails with

Error: Got unexpected undefined
    at nullthrows (/nix/store/w1synbrvnn297pzwi77jid372j4n372x-parcel-2.12.0/lib/node_modules/parcel/node_modules/nullthrows/nullthrows.js:7:15)
    at Object.<anonymous> (/nix/store/w1synbrvnn297pzwi77jid372j4n372x-parcel-2.12.0/lib/node_modules/parcel/node_modules/@parcel/node-resolver-core/lib/builtins.js:66:38)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/nix/store/w1synbrvnn297pzwi77jid372j4n372x-parcel-2.12.0/lib/node_modules/parcel/node_modules/@parcel/node-resolver-core/lib/Wrapper.js:21:41)
    at Module._compile (node:internal/modules/cjs/loader:1358:14) {
  framesToPop: 1
}

Steps To Reproduce

> nix-shell -p 'nodePackages.parcel'
$ parcel

Expected behavior

I'm just starting out with parcel, so I'm expecting at least a friendly "no input files" style error, or else have it package a Hello World HTML file. No use of parcel so far has done anything but produce the above backtrace.

Additional context

An older issue (#278462) mentions this same backtrace, and when I try to use parcel in nix-shell I see the WARNING: cannot pinpoint dependency messages @hariroshan mentioned. I'm not clear on how to implement a fix though.

Notify maintainers

@SuperSandro2000 maybe?

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.52, NixOS, 24.05 (Uakari), 24.05.20240930.1719f27`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - channels(root): `"home-manager-21.05.tar.gz, nixos-24.05, nixpkgs-24.05"`
 - channels(judson): `"home-manager-21.11, nixpkgs-21.11.337609.685d243d971"`
 - nixpkgs: `/nix/store/s9hbmmf7hgg7imnm5q6ny7gznbh0amfy-source`

Add a :+1: reaction to issues you find important.

SuperSandro2000 commented 1 month ago

No, I am definitely not a maintainer of that. You probably want to repackage it with buildNpmProject instead of node2nix.

hariroshan commented 1 month ago

Hey @nyarly,

To solve this, look for optionalDependencies in the package-lock.json, copy the correct versions of the packages to the package.json and run node2nix.

The answer was in this comment https://github.com/NixOS/nixpkgs/issues/278462#issuecomment-1880419394

open package-lock.json and find parcel object. Within that, you'll find optionalDependencies.

Basically you have to mention all or some of the dependencies with the WARNING: cannot pinpoint dependency in the package.json either in dependencies or in devDependencies.

nyarly commented 1 month ago

Okay, but: I don't have a package-lock.json or even a package.json. I'm just trying to run parcel from nixpkgs, and it's busted, seems like. From what I can tell, it's in nixpkgs via adding it to a list of packages to be generated automatically? I'm looking at pkgs/development/node-packages/node-packages.json which seems to be how parcel comes in.

@SuperSandro2000 I'm sorry to bug you with this, but you're the closest thing I can find to a maintainer here. Is there not a proper npm maintainer/team?

I guess I could try doing my own node2nix or buildNpmProject attempt with parcel; I mostly just wanted to try it out - I do a little front-end work, but I'm not specialized enough to keep up with the NPM ecosystem. I'd hoped Parcel would live up to it's promise of being a zero-config build pipeline.