* Web development on Guix: nodejs, npm and all that
@ 2022-01-10 13:17 t
2022-01-10 14:02 ` Remco
2022-01-10 14:54 ` Dr. Arne Babenhauserheide
0 siblings, 2 replies; 7+ messages in thread
From: t @ 2022-01-10 13:17 UTC (permalink / raw)
To: help-guix
Hi Guix.
Do people do web-dev on Guix System? I need to dive back into the
whole Node.js NPM ecosystem - something I've not touched for some
years and I'm wondering how people go about e.g. installing NPM
packages on Guix.
I started by reading (guix build node-build-system) as one does. I
think I have a decent grasp on exactly how it goes about
installing those NPM dependencies. Unsurprisingly you need to
package all those dependencies as Guix packages, then supply them
as inputs, whereupon the extra 'patch-dependencies phase will
actually lookup those packages in your inputs and replace deps
paths under "dependencies", "devDependencies", "peerDependencies"
with store items as needed. Configure phase actually runs local
install with --offline and --ignore-scripts which is
understandable followed by build phase which does npm run build
where the script is available. Followed by some tar and npm
install from local package dance, which I don't fully understand,
but I get the general idea and where we end up (I still haven't a
clue what 'set-home phase does and why).
This is all very cute and reproducible, but ... JS web developers
aren't exactly known for avoiding dependencies. Even just getting
express-js to run would require me to package ungodly number of
those dependencies.
If guix repo is indicative, looks like I'm not the only one to
realise packaging those would be too much work unless the entire
community somehow decides to come together and do an "NPM Summer
of Hard Unpaid Labour".
So, how do people program for the Web, Node on Guix. Does =npm
install= which defaults to local installation work well enough for
most packages? An outline of what to expect and known problems and
workarounds would be very useful.
Thank you
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Web development on Guix: nodejs, npm and all that
2022-01-10 13:17 Web development on Guix: nodejs, npm and all that t
@ 2022-01-10 14:02 ` Remco
2022-01-10 15:16 ` t
2022-01-10 14:54 ` Dr. Arne Babenhauserheide
1 sibling, 1 reply; 7+ messages in thread
From: Remco @ 2022-01-10 14:02 UTC (permalink / raw)
To: t; +Cc: help-guix
> So, how do people program for the Web, Node on Guix. Does =npm
> install= which defaults to local installation work well enough for
> most packages? An outline of what to expect and known problems and
> workarounds would be very useful.
Hi, a couple of the projects I work on depend on Node but I never ever
install npm packages globally. I setup most of my project development
environments using direnv and the node projects have an extra entry to
make the installed commands available:
PATH="$(expand_path node_modules/.bin):$PATH"
I haven't encountered any npm package which doesn't work when not
installed globally yet and it seems to me that would be a bug in said
package.
Anyway, direnv really shines with guix! It also includes a use_guix
statement to add deps using guix environment but I prefer to use
profiles instead because they are garbage collection resistant and avoid
new installs after I did a guix pull.
Cheers,
Remco
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Web development on Guix: nodejs, npm and all that
2022-01-10 13:17 Web development on Guix: nodejs, npm and all that t
2022-01-10 14:02 ` Remco
@ 2022-01-10 14:54 ` Dr. Arne Babenhauserheide
2022-01-10 18:15 ` Chris Marusich
1 sibling, 1 reply; 7+ messages in thread
From: Dr. Arne Babenhauserheide @ 2022-01-10 14:54 UTC (permalink / raw)
To: t; +Cc: help-guix
[-- Attachment #1: Type: text/plain, Size: 1140 bytes --]
Hi t,
t@fullmeta.me writes:
> Do people do web-dev on Guix System? I need to dive back into the
> whole Node.js NPM ecosystem - something I've not touched for some
> years and I'm wondering how people go about e.g. installing NPM
> packages on Guix.
> So, how do people program for the Web, Node on Guix. Does =npm
> install= which defaults to local installation work well enough for
> most packages? An outline of what to expect and known problems and
> workarounds would be very useful.
I do webdev on Guix, but I work in a team where I’m currently the only
Guix user, so my usage must work with changes we do.
I used to have a setup that used the local guix-installed npm (
https://www.draketo.de/software/guix-work#npm ), but that often broke,
so I switched to copying the
node_modules/npm/bin/npm-cli.js
script from our build environment to
~/.local/bin/npm
(which I have on my path)
with #!/usr/bin/env node as hashbang.
That now actually works pretty well, and it uses the node from Guix.
Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Web development on Guix: nodejs, npm and all that
2022-01-10 14:02 ` Remco
@ 2022-01-10 15:16 ` t
2022-01-10 23:08 ` Jelle Licht
0 siblings, 1 reply; 7+ messages in thread
From: t @ 2022-01-10 15:16 UTC (permalink / raw)
To: Remco; +Cc: help-guix
> I haven't encountered any npm package which doesn't work when not
> installed globally yet and it seems to me that would be a bug in said
> package.
this is certainly great to hear! Thank you
I've been trying to do all setup via `guix shell --container`. Is there an easy (obvious) way to extend environment inside the container? I can --preserve etc, but doesn't look like I can easily change e.g. PATH to ensure it includes local node_modules/bin. Maybe the better way would be to have the ability to set GUIX_ENVIRONMENT to a profile that you tweak which sets env vars apprpiately. I feel like maybe I'm already asking too much of the guix shell CLI front end and maybe I'm better of reversing what relevant .scm script does setting up container's environment and just drop my modified .scm script to a project dir. I hate mucking with BASH and such - never ends well and never goes smoothly.
Anyone has suggestions? Basically at this point we are trying to go slightly above what `guix shell --container` or even `guix shell` can do. Something that I feel amounts to (in non-guix world) to running a sort of .loginrc script when you enter the environment or container.
Should I just hack some .scm at this point?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Web development on Guix: nodejs, npm and all that
2022-01-10 14:54 ` Dr. Arne Babenhauserheide
@ 2022-01-10 18:15 ` Chris Marusich
2022-01-10 22:24 ` Dr. Arne Babenhauserheide
0 siblings, 1 reply; 7+ messages in thread
From: Chris Marusich @ 2022-01-10 18:15 UTC (permalink / raw)
To: Dr. Arne Babenhauserheide; +Cc: help-guix
[-- Attachment #1: Type: text/plain, Size: 1511 bytes --]
Hi,
"Dr. Arne Babenhauserheide" <arne_bab@web.de> writes:
> Hi t,
>
> t@fullmeta.me writes:
>> Do people do web-dev on Guix System? I need to dive back into the
>> whole Node.js NPM ecosystem - something I've not touched for some
>> years and I'm wondering how people go about e.g. installing NPM
>> packages on Guix.
>
>> So, how do people program for the Web, Node on Guix. Does =npm
>> install= which defaults to local installation work well enough for
>> most packages? An outline of what to expect and known problems and
>> workarounds would be very useful.
>
> I do webdev on Guix, but I work in a team where I’m currently the only
> Guix user, so my usage must work with changes we do.
>
> I used to have a setup that used the local guix-installed npm (
> https://www.draketo.de/software/guix-work#npm ), but that often broke,
> so I switched to copying the
>
> node_modules/npm/bin/npm-cli.js
>
> script from our build environment to
>
> ~/.local/bin/npm
>
> (which I have on my path)
> with #!/usr/bin/env node as hashbang.
>
> That now actually works pretty well, and it uses the node from Guix.
>
> Best wishes,
> Arne
Just to be clear: that means you're using node to manage all the
dependencies, not Guix, right? Not that there's anything wrong with
that. I'm just curious, since watching on the sidelines, I've often
heard that NPM is difficult to package in Guix.
--
Chris
PGP: https://savannah.gnu.org/people/viewgpg.php?user_id=106836
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Web development on Guix: nodejs, npm and all that
2022-01-10 18:15 ` Chris Marusich
@ 2022-01-10 22:24 ` Dr. Arne Babenhauserheide
0 siblings, 0 replies; 7+ messages in thread
From: Dr. Arne Babenhauserheide @ 2022-01-10 22:24 UTC (permalink / raw)
To: Chris Marusich; +Cc: help-guix
[-- Attachment #1: Type: text/plain, Size: 672 bytes --]
Chris Marusich <cmmarusich@gmail.com> writes:
> Just to be clear: that means you're using node to manage all the
> dependencies, not Guix, right? Not that there's anything wrong with
> that. I'm just curious, since watching on the sidelines, I've often
> heard that NPM is difficult to package in Guix.
Yes, I use npm, because that means that I can directly use our webdev
teams shared setup. Otherwise I’d have to spend too much time keeping up
to date with the versions of our dependencies (since some npm packages
require regular security updates).
Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Web development on Guix: nodejs, npm and all that
2022-01-10 15:16 ` t
@ 2022-01-10 23:08 ` Jelle Licht
0 siblings, 0 replies; 7+ messages in thread
From: Jelle Licht @ 2022-01-10 23:08 UTC (permalink / raw)
To: t, Remco; +Cc: help-guix
t@fullmeta.me writes:
>> I haven't encountered any npm package which doesn't work when not
>> installed globally yet and it seems to me that would be a bug in said
>> package.
>
> this is certainly great to hear! Thank you
>
> I've been trying to do all setup via `guix shell --container`. Is there an easy (obvious) way to extend environment inside the container? I can --preserve etc, but doesn't look like I can easily change e.g. PATH to ensure it includes local node_modules/bin. Maybe the better way would be to have the ability to set GUIX_ENVIRONMENT to a profile that you tweak which sets env vars apprpiately. I feel like maybe I'm already asking too much of the guix shell CLI front end and maybe I'm better of reversing what relevant .scm script does setting up container's environment and just drop my modified .scm script to a project dir. I hate mucking with BASH and such - never ends well and never goes smoothly.
Would prefixing your commands with 'npx' work? I can't recall any major
issues running some tools that were installed in node_modules/bin via
guix's node/npm.
>
> Anyone has suggestions? Basically at this point we are trying to go slightly above what `guix shell --container` or even `guix shell` can do. Something that I feel amounts to (in non-guix world) to running a sort of .loginrc script when you enter the environment or container.
I don't believe there is a clean solution for doing these things, but
you can probably cobble something together with bash and the --expose
flag of 'guix shell'
As other folks mentioned, this does seem more easily solved using
direnv, so that's probably what I would go for.
- Jelle
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-01-10 23:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-10 13:17 Web development on Guix: nodejs, npm and all that t
2022-01-10 14:02 ` Remco
2022-01-10 15:16 ` t
2022-01-10 23:08 ` Jelle Licht
2022-01-10 14:54 ` Dr. Arne Babenhauserheide
2022-01-10 18:15 ` Chris Marusich
2022-01-10 22:24 ` Dr. Arne Babenhauserheide
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.