hubs: NPM Install Failed `npm ci` TypeError: Invalid Version: 0.5.0a Semver

Description I clone this repo this day then i run npm ci then it give me error.

image

Then i open the logs /Users/susanto/.npm/_logs/2022-05-29T01_20_33_271Z-debug.log

13533 timing metavuln:packument:portfinder Completed in 0ms
13534 timing metavuln:packument:easyrtc Completed in 0ms
13535 timing metavuln:packument:htmlhint Completed in 0ms
13536 timing metavuln:packument:jake Completed in 0ms
13537 timing metavuln:cache:get:security-advisory:easyrtc:BlxKEDoAFuaVWbFrTgG3Pi8ec6FE1r/PxWoHWiF0zq/Cw4Da3v6oUEno4mEmhMBSGMPbMwealofo3HV6/f4sdw== Completed in 0ms
13538 verbose stack TypeError: Invalid Version: 0.5.0a
13538 verbose stack     at new SemVer (/Users/susanto/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/semver/classes/semver.js:38:13)
13538 verbose stack     at compareBuild (/Users/susanto/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/semver/functions/compare-build.js:4:20)
13538 verbose stack     at /Users/susanto/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/semver/functions/sort.js:2:51
13538 verbose stack     at Array.sort (<anonymous>)
13538 verbose stack     at Object.sort (/Users/susanto/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/semver/functions/sort.js:2:36)
13538 verbose stack     at Advisory.[calculateRange] (/Users/susanto/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/@npmcli/metavuln-calculator/lib/advisory.js:159:28)
13538 verbose stack     at Advisory.load (/Users/susanto/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/@npmcli/metavuln-calculator/lib/advisory.js:148:28)
13538 verbose stack     at Calculator.[calculate] (/Users/susanto/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/@npmcli/metavuln-calculator/lib/index.js:59:14)
13538 verbose stack     at async Promise.all (index 1)
13538 verbose stack     at async Map.[init] (/Users/susanto/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:192:7)
13539 verbose cwd /Users/susanto/Documents/Proyek/M/hubs
13540 verbose Darwin 21.4.0
13541 verbose argv "/Users/susanto/.nvm/versions/node/v16.13.0/bin/node" "/Users/susanto/.nvm/versions/node/v16.13.0/bin/npm" "ci"
13542 verbose node v16.13.0
13543 verbose npm  v8.1.0
13544 error Invalid Version: 0.5.0a
13545 verbose exit 1

I try delete the node_modules folder and package-lock.json -> npm install -> Still getting same error

I try delete the node_modules folder and package-lock.json -> npm clean cache -> npm install -> Still getting same error

I using this.

image

Hardware

  • Device: Macbook Air M1
  • OS: Mac OS 12.3.1 (21E258)
  • Browser: Chrome latest

Assumption Dependency is broken.

  • Package in github repo in package json is using some github branch to link the dependencies like “package_name” : “github:blabla…”

what if this package is updated ? and crash

  • Package with up version in package json is using some ^ to keep up to date with version. like “package_name” : “^0.1.0”

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (2 by maintainers)

Most upvoted comments

Thanks @msalafia for digging into this. It looks like we don’t actually even need the easyrtc dependency that is causing issues so I am just going to remove it from our networked-aframe fork.

Tomorrow i will spend my time on this

Changing version of npm and node doesn’t fix this issue for me. I have notced that the problem is due to easyrtc. in fact npm runs the command curl https://registry.npmjs.org/easyrtc and i think tries to parse the versions with semver and fail on 0.5.0a.

In the following a piece of the curl result:

"time" : {
      "0.10.2-alpha" : "2013-10-29T00:51:47.227Z",
      "0.10.3-alpha" : "2013-11-18T04:30:37.152Z",
      "0.10.4-alpha" : "2013-11-19T08:26:50.049Z",
      "0.5.0" : "2012-12-13T01:16:25.229Z",
      "0.5.0a" : "2012-12-11T17:49:08.661Z",   // <------- What generates the issue
      "0.6.0" : "2012-12-20T21:18:24.848Z",
      "0.7.0" : "2013-02-04T20:44:55.665Z",
      "0.8.0" : "2013-05-30T23:00:59.212Z",
      "0.9.0" : "2013-08-09T20:24:31.035Z",
      "1.0.0-beta" : "2013-11-19T09:06:20.827Z",
      "1.0.1-beta" : "2013-11-20T19:02:13.538Z",
      "1.0.10" : "2014-03-05T23:18:02.596Z",
      "1.0.11" : "2014-05-21T00:08:28.163Z",
      "1.0.12" : "2014-08-06T18:58:01.895Z",
      "1.0.13" : "2015-02-16T22:25:32.667Z",
      "1.0.14" : "2015-07-14T15:19:57.922Z",
      "1.0.15" : "2015-10-29T23:00:14.195Z",
      "1.0.2-beta" : "2013-11-21T00:43:21.625Z",
      "1.0.5-beta" : "2013-12-05T05:08:01.262Z",
      "1.0.6-beta" : "2013-12-13T23:28:06.573Z",
      "1.0.7" : "2013-12-19T01:03:54.534Z",
      "1.0.8" : "2014-01-21T19:14:26.873Z",
      "1.0.9" : "2014-02-07T23:51:17.318Z",
      "1.1.0" : "2016-10-19T22:40:17.989Z",
      "created" : "2012-12-11T17:49:06.040Z",
      "modified" : "2022-05-28T00:47:43.010Z"  // <--- something changed two days ago, just when this issue raised
   },

As you can see something has been modified few days ago, just when this issue raised. I don’t have any ideas how to solve this.

I think that the version of networked-aframe forked by mozilla reality and used in hubs is too old and needs to be alligned or at least remove easyrtc and replace it with open-easyrtc.

I generated a patch file based on the suggestions here to remove easyrtc from both package-lock.json files, it is located here.

Strangely, this fix did not work on two of my machines. I put together a basic Docker setup to run Mozilla Hubs in development; the above patch file is located in that repository. Hopefully, if others stumble across this issue and still experience problems like I did, the aforementioned repository will save you a headache – or two!

I also had this problem with ubuntu20.04. I solved this problem by updating the latest code for the Hubs project master branch, which also updates Node to 16.16.0. 1659619575911

Little update to help make this easy. This error still seems to pop up even after downloading the latest git version. Here are my tricks to get this to install pretty painlessly on fresh install of Centos 8. Bottom half should work for anyone running into this issue. I know this isnt very elegant but its working for me, but parts may help you. Use at your own risk. This fix will not work long term as it locks you into specific packages. It will break any future upgrades to package that are locked but should be upgraded based on devs new needs.

big ups and big shouts to @albirrkarim for this over here: https://github.com/albirrkarim/mozilla-hubs-installation-detailed/blob/main/ADVICE.md#--lock-the-version-of-package-by-commit-hash this ended up being the main key for me.

centos 8 specific steps:

dnf install git dnf module install nodejs:16 dnf install nodejs dnf install npm dnf module enable postgresql:12 dnf install postgresql-server

install steps:

do not run the below as root.

if you tried to install and it failed… delete the ./hubs directory, then make sure you delete the /home/USERNAME/.npm folder first.

cd /your/project/dir git clone https://github.com/{YOURACCOUNT}/hubs.git cd hubs git checkout hubs-cloud git remote add upstream https://github.com/mozilla/hubs.git

You will need to edit 3 total files.

vi the ./package.json file from the root of your project. Change these lines: image

to match this: image

vi the ./package-lock.json from the root of your project… change these easyrtc lines:

Change this: image

to this: image

Remove easyrtc reference here: image

to this: image

vi the ./admin/package-lock.json file and change these lines: image

to this image

change this easyrtc reference from this: image

to this: image

change this: image

to this: image

in the root of your app do an npm install if it finishes with no errors, You will see warnings… but you “should” be ok to ignore them.

npm run dev should work.

image

Just in case if anyone else is having the same issue. I succeeded in npm ci with node 14.

I tried following this guide Custom-Hubs-Components

and install nvm to use node 14.19.3 and it works without any modification on package-lock.json

@truknbass My reply is late. Yes, in my experience, npm ci also fails, so let’s use npm install . I was able to finish the installation.

You’ve worked hard. have a good day.

After a fair amount of trail and error, under centos 8, npm version 8.3.1, node js, v16.14.0 I got this to work around the 0.5.0a error.

Fresh install only. New clone of git to new folder. Before running any commands remove easyrtc from package-lock.json in both admin and root folders based on @demzou suggested, finally running npm install. Things seem to work with that. I am able to start the client, and start the dev server. If I run the npm ci command, it re-downloads everything, removes my changes and fails.

Building what @jbshin-gemiso wrote above, I had to fiddle around a tiny bit more to make it work. I was still getting errors when trying to deploy. Describing it here in case it helps:

  1. In the package-lock.json file, search for ‘easyrtc’ and delete the full dependency section. Do this on the package-lock.json file at the root AND in the admin folder

It was located at line 14982 in my file:

   "easyrtc": {
          "version": "1.1.0",
          "resolved": "https://registry.npmjs.org/easyrtc/-/easyrtc-1.1.0.tgz",
          "integrity": "sha1-9Ek39xMsuLW6jgvBzD48zEcqPvQ=",
          "requires": {
            "async": "0.2.x",
            "colors": "*",
            "underscore": "1.5.x"
          },
          "dependencies": {
            "async": {
              "version": "0.2.10",
              "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz",
              "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E="
            }
          }
        },
  1. Clear npm cache. I used ‘npm cache clean --force’ (npm cache verify wasn’t working and a simple clean was returning errors, so I had to force it)

  2. Delete ‘node_modules’ folder at the root AND in admin

  3. npm install

  4. npm ci (not sure both are necessary, but it worked)

I succeed doing this with yarn install for full explanation about my approach take a look on my repo, and please give me star.

https://github.com/albirrkarim/mozilla-hubs-installation-detailed/blob/main/ADVICE.md#avoid-dependency-crash