Help with npm install in old Elixir app

I have an old app built using:

erlang 24.2.1

elixir 1.13.2-otp-24

nodejs 16.13.2

I’m afraid to upgrade anything, as it will likely break the app.

I’m trying to install npm dependencies in package.json

running npm install in the package.json’s directory, I get these errors:

npm WARN deprecated core-js@2.6.11: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.

npm ERR! code 1

npm ERR! path /home/user/Applications/cl/apps/swing/assets/node_modules/elm

npm ERR! command failed

npm ERR! command sh -c binwrap-install

npm ERR! fs.js:47

npm ERR! } = primordials;

npm ERR! ^

npm ERR!

npm ERR! ReferenceError: primordials is not defined

npm ERR! at fs.js:47:5

npm ERR! at req_ (/home/user/Applications/cl/apps/swing/assets/node_modules/natives/index.js:143:24)

npm ERR! at Object.req [as require] (/home/user/Applications/cl/apps/swing/assets/node_modules/natives/index.js:55:10)

npm ERR! at Object.<anonymous> (/home/user/Applications/cl/apps/swing/assets/node_modules/unzip/node_modules/graceful-fs/fs.js:1:37)

npm ERR! at Module._compile (node:internal/modules/cjs/loader:1101:14)

npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)

npm ERR! at Module.load (node:internal/modules/cjs/loader:981:32)

npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:822:12)

npm ERR! at Module.require (node:internal/modules/cjs/loader:1005:19)

npm ERR! at require (node:internal/modules/cjs/helpers:102:18

I tried changing permissions in the folder to the most liberal possible.

I tried npm install core-js@latest
I’ve checked for conflicts between nodejs & npm version:

nodejs v16.13.2
npm 8.1.2

… they shouldn’t conflict.

Tried upgrade npm to 9.6.5 with nodejs v16.13.2. then running pm update -g

I’m still getting the same issue.

Upgrading Node will not help, this problem is because the version of Node (any version > 11) is too new for some of the dependencies:

1 Like

So I either downgrade > 11, or add?:

  "scripts": {
    "preinstall": "npx npm-force-resolutions"
  "resolutions": {
    "graceful-fs": "^4.2.10"

What unintended consequences might this override lead to?

I’d personally do something like that dead last after exhausting all other approaches.

Is this project a framework like Phoenix? For older projects where Node may be missing, I look for the release date in the very first commit. If this was Phoenix 1.2 for example (i.e. 5 releases ago), I would look for the date that was released on Google/Wikipedia. I would then match the Node release for the stable LTS version around that timeframe. I’ll lock asdf to the latest minor revision.

Elixir 1.13 and Node 16 are pretty new and it’s not usual to see this paired with Node 10 packages out of the gate. With asdf I tend to keep the npm versions locked to the Node runtime even though it complains. Newer versions of npm can work against older runtimes but it’s generally more trouble than it’s worth.

In extreme cases I will do the following:

  1. Lock node using asdf local or global.
  2. Run npm install. If no errors, finish.
  3. If an error occurred, continue.
  4. Delete node_modules
  5. Lock node to one earlier major version, repeat the install.

It’s always possible that a project was upgraded to a state that won’t install without errors but there is usually a timeframe where it had zero issues. That’s the place I always try to get to and it can use a bit of detective work. With asdf it’s generally easier to troubleshoot runtimes than it is trying to lock dependencies to earlier versions.

1 Like

You might also check for available npm packages updates…

cd assets
npm outdated

…then carefully check if updating packages is possible.