NPM install error on Ubuntu: npm ERR! node install.js

Hello,

I attempted installing Elm on Ubuntu 16.04.6 LTS, using this command:

npm install -g elm

I did install nodejs and the nodejs-legacy (from another tutorial i found), but its not progressing beyond this error below. Any thoughts of how I can progress?

Thank you.

+++++++++++++++++++++++++++++++++++++++++++++++++
TypeError: Object.values is not a function
at Object. (/usr/local/lib/node_modules/elm/install.js:8:49)
at Module._compile (module.js:410:26)
at Object.Module._extensions…js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
npm ERR! Linux 4.4.0-157-generic
npm ERR! argv “/usr/bin/nodejs” “/usr/bin/npm” “install” “elm” “–global”
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! elm@0.19.0-no-deps install: node install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the elm@0.19.0-no-deps install script ‘node install.js’.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the elm package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs elm
npm ERR! Or if that isn’t available, you can get their info via:
npm ERR! npm owner ls elm
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /root/npm-debug.log

+++++++++++++++++++++++++++++++++++++++++++++++++
npm-debug.log (https was replaced with ‘xxxx’ in order to post
+++++++++++++++++++++++++++++++++++++++++++++++++
1 verbose cli [ ‘/usr/bin/nodejs’, ‘/usr/bin/npm’, ‘install’, ‘elm’, ‘–global’ ]
2 info using npm@3.5.2
3 info using node@v4.2.6
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData elm
8 silly fetchNamedPackageData elm
9 silly mapToRegistry name elm
10 silly mapToRegistry using default registry
11 silly mapToRegistry registry xxxx://registry.npmjs.org/
12 silly mapToRegistry uri xxxx://registry.npmjs.org/elm
13 verbose request uri xxxx://registry.npmjs.org/elm
14 verbose request no auth needed
15 info attempt registry request try #1 at 2:16:35 AM
16 verbose request id 263142242324111f
17 verbose etag W/“b2142e135be22b8021f4dc1923412e0b”
18 verbose lastModified Sat, 11 May 2019 13:52:40 GMT
19 http request GET xxxx://registry.npmjs.org/elm
20 http 304 xxxx://registry.npmjs.org/elm
21 verbose headers { date: ‘Sun, 22 Sep 2019 06:16:35 GMT’,
21 verbose headers connection: ‘keep-alive’,
21 verbose headers ‘set-cookie’: [ '__cfduid=d1fff7a411e27f28eff4bfabcf3825f2b1569132995; expires=Mon, 21-Sep-20 06:16:35 GMT; p$
21 verbose headers ‘cf-cache-status’: ‘HIT’,
21 verbose headers ‘cache-control’: ‘max-age=300’,
21 verbose headers ‘cf-ray’: ‘51a226a53dc4e710-EWR’,
21 verbose headers age: ‘1140’,
21 verbose headers etag: ‘“b2142e135be22b8021f4dc1923412e0b”’,
21 verbose headers ‘expect-ct’: ‘max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct”’,
21 verbose headers ‘last-modified’: ‘Sat, 11 May 2019 13:52:40 GMT’,
21 verbose headers vary: ‘accept-encoding, accept’,
21 verbose headers ‘x-amz-meta-rev’: ‘139-af23d3b387cc08e78ad161435f99dbcc’,
21 verbose headers server: ‘cloudflare’ }
22 silly get cb [ 304,
22 silly get { date: ‘Sun, 22 Sep 2019 06:16:35 GMT’,
22 silly get connection: ‘keep-alive’,
22 silly get ‘set-cookie’: [ '__cfduid=d1fff7a411e27f28eff4bfabcf3825f2b1569132995; expires=Mon, 21-Sep-20 06:16:35 GMT; path=$
22 silly get ‘cf-cache-status’: ‘HIT’,
22 silly get ‘cache-control’: ‘max-age=300’,
22 silly get ‘cf-ray’: ‘51a226a53dc4e710-EWR’,
22 silly get age: ‘1140’,
22 silly get etag: ‘“b2142e135be22b8021f4dc1923412e0b”’,
22 silly get ‘expect-ct’: ‘max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct”’,
22 silly get ‘last-modified’: ‘Sat, 11 May 2019 13:52:40 GMT’,
22 silly get vary: ‘accept-encoding, accept’,
22 silly get ‘x-amz-meta-rev’: ‘139-af23d3b387cc08e78ad161435f99dbcc’,
22 silly get server: ‘cloudflare’ } ]

Looks like your NodeJS version is too old Object.values is not a function - your Ubuntu probably comes with v6, current LTS is 10. I’d recommend installing an LTS version from https://github.com/nodesource/distributions

1 Like

Thank you, thank you, this likely saved me from hours upon hours of headaches.

You solution help me get through most of the issue. I still got one permission issue (below), but I found the solution in this thread:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

:~# sudo npm install -g elm
/usr/bin/elm -> /usr/lib/node_modules/elm/bin/elm

elm@0.19.0-no-deps install /usr/lib/node_modules/elm
node install.js

– ERROR -----------------------------------------------------------------------

I had some trouble writing file to disk. It is saying:

Error: EACCES: permission denied, open ‘/usr/lib/node_modules/elm/bin/elm’

NOTE: You can avoid npm entirely by downloading directly from:
https://github.com/elm/compiler/releases/download/0.19.0/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.0-no-deps install: node install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the elm@0.19.0-no-deps install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-09-22T07_29_09_155Z-debug.log
root@vonbuntu:~# sudo npm install -g elm --unsafe-perm=true --allow-root
/usr/bin/elm -> /usr/lib/node_modules/elm/bin/elm

elm@0.19.0-no-deps install /usr/lib/node_modules/elm
node install.js

I usually install elm locally for the project because I find global dependencies to be a hazzle

mkdir path/to/your-project && cd path/to/your-project
npm init (or yarn init)
npm install --save-dev elm (or yarn add --dev elm)

this will install the Elm binary as your-project/node_modules/.bin/elm which you can execute inside your project directory with npx elm - npx is a tool that comes with NPM and allows you to run locally installed stuff from node_modules; outside of an NPM directory structure it pulls the latest stable version and runs it without you needing to install it, this is nice for one-off setups. You could also add ./node_modules/.bin/ to your $PATH variable which enables running commands “normally” from the project root.

Once Elm is installed locally you can use the “scripts” part of your package.json to run your dependencies, inside an NPM script it knows about the node_modules directory

{
  "scripts: {
    "build": "elm make src/Main.elm --output=dist/app.js"
  }
}
2 Likes

Someone else on discourse has had the same problems Error installing elm by npm there the solution seems to have been found in the npm docs

1 Like

Thank you once again for the your responses, these help me finally install elm on my Ubuntu machine. I hope this can also be useful for others with the same problem.

In the future, I am going to be pointing Linux folks to these instructions for installation.

We have had continuous problems with the npm installer, which is nuts considering that all it needs to do is download a file. I am told that lots of people like having an npm installer if they have some JS based build system, so it will stick around, but I am hopefull that providing a path that does not use npm at all will have better outcomes for beginners.

7 Likes

Has no-one made some proper distribution packages for it yet? .deb and .rpm.

This is actually a good idea!
I’ll try and do it (and produce docs on how to do it, which is the important part)

Packaging a single executable which rarely changes seems like an overkill to me.

Packaging has many additional advantages, like package signing, the possibility to create a repository in order to have integration with the operating system automatic updates, it also has been the core of Linux distributions since the last century, so any little bit you know of Linux almost for sure includes installing packages and adding repositories.

Also a package could contain elm, but also elm-format, elm-json and other related tooling. Or if that is not the way to do it, a meta package (or whatever they call them) could exist that installs Elm and all related tooling as a collection of packages each with a single tool in it.

Good God those might be the best installation instructions for Linux I’ve ever seen. :clap: @evancz :clap:

2 Likes

Working on it: https://github.com/miniBill/elm-packaged
For now it only builds two debs for 32 and 64 bit, but I plan to expand to format, test, …

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.