Installing elm-pages (and other packages that depend on elm)

I’m struggling to install the elm-pages package. I followed the readme and cloned the elm-pages-starter template.

I first tried to npm install it, which failed:

> gifsicle@4.0.1 postinstall /tmp/elm-pages-starter/node_modules/gifsicle
> node lib/install.js

  ⚠ spawn /tmp/elm-pages-starter/node_modules/gifsicle/vendor/gifsicle ENOENT
  ⚠ gifsicle pre-build test failed
  ℹ compiling from source
  ✖ Error: Command failed: /bin/sh -c autoreconf -ivf
/bin/sh: autoreconf: command not found

I then thought I’d use node2nix, so I ran node2nix -l, which completed successfully. However, nix-shell -A shell fails, because apparently elm-pages has a dependency to elm, which, in its install script, tries to download the compiler binary, which fails because the network is not accessible during this phase.

> elm@0.19.1-3 install /nix/store/dw6jqasxzc28z55iiamymmp1gqg07ixh-node-dependencies-elm-pages-example-1.0.0/elm-pages-example/node_modules/elm
> node install.js

--------------------------------------------------------------------------------

Downloading Elm 0.19.1 from GitHub.

NOTE: You can avoid npm entirely by downloading directly from:
https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz
All this package does is download that file and put it somewhere.

--------------------------------------------------------------------------------

-- ERROR -----------------------------------------------------------------------

Something went wrong while fetching the following URL:

https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz

It is saying:

Error: getaddrinfo ENOTFOUND github.com

NOTE: You can avoid npm entirely by downloading directly from:
https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz
All this package does is download that file and put it somewhere.

--------------------------------------------------------------------------------

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! elm@0.19.1-3 install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the elm@0.19.1-3 install script.

I’ve tried removing the elm package manually from the generated node-packages.nix, but got an error with another package that also downloads something during the install phase:

> sharp@0.23.4 install /nix/store/bcr9pq8qac1wxd1ldnkfv49b22k4m8rz-node-dependencies-elm-pages-example-1.0.0/elm-pages-example/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
unpacking source archive /nix/store/ifminfmdnsyyinwsfk7c6l2m9zcx24qi-sprintf-js-1.0.3.tgz
info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.8.1/libvips-8.8.1-linux-x64.tar.gz
ERR! sharp getaddrinfo ENOTFOUND github.com
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies
make: Entering directory '/nix/store/bcr9pq8qac1wxd1ldnkfv49b22k4m8rz-node-dependencies-elm-pages-example-1.0.0/elm-pages-example/node_modules/sharp/build'
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp/src/common.o
../src/common.cc:25:10: fatal error: vips/vips8: No such file or directory
   25 | #include <vips/vips8>
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [sharp.target.mk:131: Release/obj.target/sharp/src/common.o] Error 1
make: Leaving directory '/nix/store/bcr9pq8qac1wxd1ldnkfv49b22k4m8rz-node-dependencies-elm-pages-example-1.0.0/elm-pages-example/node_modules/sharp/build'

I’m out of ideas. I guess I could try to package the elm-pages package, but I’m really scared by the list of dependencies. I would just like to try out the elm-pages package, I don’t need the solution to be clean or perfect.

Any suggestion is appreciated!

2 Likes

I’m having the same issue myself. Built a blog on MacOS some time ago, but could not get it working with NixOS. Not even with the new webpack version. Luckily I still have a computer with MacOS. Another Linux distro would probably also work.

If elm-pages wouldn’t demand Elm to be installed through npm, and rather check if Elm is installed in any other way first, I imagine it would work by installing elm through nix instead. But that might be a decision the creator would have to make.

I ran into the same problem just today. Luckily, I found your thread learning that least I’m not too stupid to use nix. :slight_smile:

If you or anyone needs a quick workaround: nix-shell -p nodejs autoreconfHook seems to bring the proper toolchain so you can at least hack on your project on a nix machine. Building for deployment will fail, but starting the dev server works.

elm-pages 2.0 was released yesterday. From the release notes:

v2 has removed Webpack, as well as many other NPM dependencies.

npm install elm-pages now works for me! :tada: