create-elm-app
create-elm-app copied to clipboard
Failed to install elm packages (on debian stable)
Bug
after installing create-elm-app with npm
running (as user of root)
$ create-elm-app mijn-portofolie
Creating mijn-portofolie project...
Failed to install elm packages
Please, make sure you have internet connection!
In case if you are running Unix OS, you might look in to this issue:
https://github.com/halfzebra/create-elm-app/issues/10
So there is a reference to issue 10, all elm npm packages are installed globally
Environment
Packages are installed from debian stable if available, otherwise from npm
-
node -v
:v10.15.2 -
npm -v
:5.8.0 -
npm ls create-elm-app -g
(if you havenβt ejected): /usr/local/lib βββ [email protected]
Then, specify:
- Operating system: Debian 10 Buster
Steps to Reproduce
- On debian stable
- install nodejs and npm package
- npm install -g create-elm-app
- create-elm-app mytest
Installing everythin with the newest versions available from npm for debian ({"os":"linux","arch":"x64"}) also does not work
$ npm -v 6.14.4 $ nodejs -v v10.15.2
Dependecies:
Side note: deprecated but used by create-elm-app:
- resolve-url
- request
- urix
not supported on linux:
- [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
- version in use is: [email protected]
Also tried with
$ node -v
v12.16.2
(no improvement)
as to one of the reference in issue #10
/usr/local/lib/node_modules/create-elm-app/node_modules# ls el* -d
electron-to-chromium elm-asset-webpack-loader elmi-to-json
elliptic elm-hot elm-test
elm elm-hot-webpack-loader elm-webpack-loader
Hi @wibrt!
Thanks for reporting this issue, have you tried one of those solutions suggested in https://github.com/halfzebra/create-elm-app/issues/26#issuecomment-494555432?
Yes, the install works,
$ ls /usr/local/lib/node_modules/create-elm-app/node_modules/el electron-to-chromium/ elm-asset-webpack-loader/ elmi-to-json/ elliptic/ elm-hot/ elm-test/ elm/ elm-hot-webpack-loader/ elm-webpack-loader/
$ ls /usr/local/lib/node_modules/create-elm-app/node_modules/elm bin download.js install.js package.json README.md
$ ll /usr/local/lib/node_modules/create-elm-app/node_modules/elm/bin/ totaal 27728 -rwxr-xr-x 1 28392488 apr 24 11:13 elm
Just to make sure i use this elm binary, the same elm version is also globally installed.
$ ./elm
Hi, thank you for trying out Elm 0.19.1. I hope you like it!
-------------------------------------------------------------------------------
I highly recommend working through <https://guide.elm-lang.org> to get started.
It teaches many important concepts, including how to use `elm` in the terminal.
-------------------------------------------------------------------------------
The most common commands are:
elm repl
Open up an interactive programming session. Type in Elm expressions like
(2 + 2) or (String.length "test") and see if they equal four!
elm init
Start an Elm project. It creates a starter elm.json file and provides a
link explaining what to do from there.
elm reactor
Compile code with a click. It opens a file viewer in your browser, and
when you click on an Elm file, it compiles and you see the result.
There are a bunch of other commands as well though. Here is a full list:
elm repl --help
elm init --help
elm reactor --help
elm make --help
elm install --help
elm bump --help
elm diff --help
elm publish --help
Adding the --help flag gives a bunch of additional details about each one.
Be sure to ask on the Elm slack if you run into trouble! Folks are friendly and
happy to help out. They hang out there because it is fun, so be kind to get the
best results!
$ create-elm-app test
Creating test project...
Failed to install elm packages
Please, make sure you have internet connection!
In case if you are running Unix OS, you might look in to this issue:
https://github.com/halfzebra/create-elm-app/issues/10
In my opinion elm-create-app should avoid depending on npm installation of elm
and ideally even other things that depend on binwrap
(elm-test, elm-format, elmi-to-json). In nixpkgs we have custom scripts to patch create-elm-app. You can have a look into this PR for some inspiration https://github.com/NixOS/nixpkgs/pull/85324
I think you might be able hotfix this on your machine by running this:
$ ln -sf $(which elm) ls /usr/local/lib/node_modules/create-elm-app/node_modules/elm/bin/elm
In addition you might need to no-op
the install.js
For a reason that i don't understand, this works now.
An upgrade to 4.2.13 (from 4.2.11) seemed to fix the problem.
Thank you.
I think the problem was that install.js script for npm installation elm didin't finish successfully so create-elm-app was calling into existing nodejs wrapper but this wrapper was unable to call the binary of compiler.
I still have this problem (doing this within a dockerfile). Versions:
- node v10.19.0
- npm 6.13.4
- elm 0.19.1
- create_elm_app 5.9.0
I tried everything that came in this issue #434 as well as issue #10 Any further ideas?
what does "this problem" mean? If you get failed to install packages
check your permissions. Also saying just Dockerfile doesn't help much - are you using Debian as a base image?
Okay so the Dockerfile is this
FROM alpine:3.10.2
ENV APP_HOME /app
WORKDIR $APP_HOME
VOLUME $APP_HOME
RUN apk add git nodejs npm
RUN npm install -g --unsafe-perm=true elm create-elm-app elm-format elmstatic
ENV ELM_HOME=$APP_HOME/.elm-home
RUN mkdir -p $APP_HOME/.elm-home
CMD ["sh"]
This is the output
/app # create-elm-app test
Creating test project...
Failed to install elm packages
Please, make sure you have internet connection!
In case if you are running Unix OS, you might look in to this issue:
https://github.com/halfzebra/create-elm-app/issues/10
As the container is running as root I am not quite sure whether permissions might be a problem here. Yet I might be completely wrong.
Any pointers to further information, or tips are really appreciated.
So this is where it fails for you:
https://github.com/halfzebra/create-elm-app/blob/55547b0195706ecebfe5c0dbc961b8f5f3a27196/scripts/create.js#L46-L67
Things to try:
- try to run
npm run postinstall
manually. - have a look if
../node_modules/.bin/elm
exists. - if it doesn't exist symlink elm binary there as desribed https://github.com/halfzebra/create-elm-app/issues/434#issuecomment-619873073 (just update the paths to match your system).
So my /app folder is empty, as I want to create a new app into this, with create-elm-app.
Here is the output to npm run postinstall
/app # npm run postinstall
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /app/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-10-26T15_09_25_638Z-debug.log
Of course I don't have a /app/package.json.
Now about ../node_modules/.bin/elm
. What is the source supposed to be here?
- if it is /app, There is no /node_modules...
- if it is $HOME, there is no node_modules either
- if it is /usr/lib/.node_modules, there is no .bin in here. I created one, and symlinked like this:
/usr/lib/node_modules # ls -la .bin/
total 8
drwxr-xr-x 2 root root 4096 Oct 26 15:11 .
drwxr-xr-x 1 root root 4096 Oct 26 15:11 ..
lrwxrwxrwx 1 root root 33 Oct 26 15:11 elm -> /usr/lib/node_modules/elm/bin/elm
Yet, after this neither create-elm-app
nor npm run postinstall
do anything different than described here.
Thank you for your help so far, if there is anything more I can do, read, or try, I'm open to everything.
npm (actually node itself I believe) has rules about how it goes about resolving node modules you can check it. If you don't have local node_modules
yhou need to check global ones. use npm config get prefix
you can also use set prefix to set it to the location where you want to install global node modules (probably should be in PATH though). I think this is all documented -- man npm
.
Okay, after some parsing and figuring out, here is my solution: This is my dockerfile now:
FROM alpine:3.10.2
# install npm and needed modules for elm
RUN apk add git nodejs npm
RUN npm install -g --unsafe-perm=true elm create-elm-app elm-format elmstatic
WORKDIR /usr/lib/node_modules/create-elm-app
RUN npm install # rerun install for create-elm-app
ENV ELM_HOME=$APP_HOME/.elm-home
RUN mkdir -p $APP_HOME/.elm-home
ENV APP_HOME /app
WORKDIR $APP_HOME
VOLUME $APP_HOME
CMD ["sh"]
So we need to go into /usr/lib/node_modules/create-elm-app
and run npm install
here, for the file /usr/lib/node_modules/create-elm-app/node_modules/.bin/elm
to be created. So this is the ../node_modules...
file that was mentioned.
It is sad that the plain npm install -g create-elm-app
is not enough for everything to work, and I am not sure what the cause for this is. At least I got my result and maybe could help some other people with this.
My guess is that for security reasons npm doesn't run post-install scripts when being run as a root. This is understandable because allowing this means that package can do anything to your system during installation.