Hubs-Foundation / hubs

Duck-themed multi-user virtual spaces in WebVR. Built with A-Frame.
https://hubsfoundation.org
Mozilla Public License 2.0
2.14k stars 1.41k forks source link

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

Closed albirrkarim closed 2 years ago

albirrkarim commented 2 years ago

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

Assumption Dependency is broken.

what if this package is updated ? and crash

x-EricH-x commented 2 years ago

I had the same issue, tried with node 18 and 16, and eventually got it working when switched to node 14.

vvdt commented 2 years ago

Same issue here (Macbook Pro M1). Cleared cache, tried different versions of Node and finally got it working with node v15.3.0 (npm v7.0.14)

msalafia commented 2 years ago

I had the same issue! what happened? I tried with node v16.14.2 (npm v8.6.0) but also with node v15.3.0 (npm v7.0.14)as suggested by @vvdt, but still getting the error

3771 verbose stack TypeError: Invalid Version: 0.5.0a
3771 verbose stack     at new SemVer (/Users/marcosalafia/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/semver/classes/semver.js:38:13)
3771 verbose stack     at compareBuild (/Users/marcosalafia/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/semver/functions/compare-build.js:4:20)
3771 verbose stack     at /Users/marcosalafia/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/semver/functions/sort.js:2:51
3771 verbose stack     at Array.sort (<anonymous>)
3771 verbose stack     at Object.sort (/Users/marcosalafia/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/semver/functions/sort.js:2:36)
3771 verbose stack     at Advisory.[calculateRange] (/Users/marcosalafia/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/@npmcli/metavuln-calculator/lib/advisory.js:167:28)
3771 verbose stack     at Advisory.load (/Users/marcosalafia/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/@npmcli/metavuln-calculator/lib/advisory.js:155:28)
3771 verbose stack     at Calculator.[calculate] (/Users/marcosalafia/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/@npmcli/metavuln-calculator/lib/index.js:60:14)
3771 verbose stack     at async Promise.all (index 1)
3771 verbose stack     at async Map.[init] (/Users/marcosalafia/.nvm/versions/node/v16.14.2/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:191:7)
3772 verbose cwd /Users/marcosalafia/Documents/Projects/hubs

I am using a Macbook Pro M1. I used the command npm ci --legacy-peer-deps.

markusTraber commented 2 years ago

Also affected. Was on node v16.15.0 and now tried with v15.3.0 and it seems to work. Macbook Pro M1.

msalafia commented 2 years ago

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.

albirrkarim commented 2 years ago

Tomorrow i will spend my time on this

albirrkarim commented 2 years ago

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

msalafia commented 2 years ago

Using yarn doesn't work for me. Even though it install everything without errors, when i do npm start i have lot of errors due to babel like:

ERROR in ./src/support.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: [BABEL]: (0 , _helperPluginUtils.declarePreset) is not a function (While processing: /Users/marcosalafia/Documents/Projects/hubs/node_modules/@babel/preset-env/lib/index.js)
    at Object.<anonymous> (/Users/marcosalafia/Documents/Projects/hubs/node_modules/@babel/preset-env/lib/index.js:250:53)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at loadCjsDefault (/Users/marcosalafia/Documents/Projects/hubs/node_modules/@babel/core/lib/config/files/module-types.js:89:18)
    at loadCjsOrMjsDefault (/Users/marcosalafia/Documents/Projects/hubs/node_modules/@babel/core/lib/config/files/module-types.js:61:16)
    at loadCjsOrMjsDefault.next (<anonymous>)
    at requireModule (/Users/marcosalafia/Documents/Projects/hubs/node_modules/@babel/core/lib/config/files/plugins.js:264:44)
    at requireModule.next (<anonymous>)
    at loadPreset (/Users/marcosalafia/Documents/Projects/hubs/node_modules/@babel/core/lib/config/files/plugins.js:102:24)
    at loadPreset.next (<anonymous>)
    at createDescriptor (/Users/marcosalafia/Documents/Projects/hubs/node_modules/@babel/core/lib/config/config-descriptors.js:187:16)
    at createDescriptor.next (<anonymous>)

Maybe i am doing something wrong. I never used yarn before.

By the way, using yarn can be a workaround for this issue but it is not something feasible in my case. There are too much scripts that relies on npm (like deploy.js) and i cannot change them.

albirrkarim commented 2 years ago

what npm start do ?

btw i use npm run local for run locally

msalafia commented 2 years ago

We use npm start for (as documented in package.json) "Run the client against your Hubs Cloud instance, or Mozilla's developer infrastructure,\n using application configs pulled from the server".

npm run local i think it's for running hubs against a local reticulum server which we doesn't have.

netpro2k commented 2 years ago

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.

BarakChamo commented 2 years ago

@netpro2k this is still present on the hubs-cloud branch. Since this is a cloud particular issue it's confusing to mark it as closed. Would be good to know when this is merged to the cloud branch.

ClarkDuck commented 2 years ago

@netpro2k

I have npm ci error with following message.


2022-06-07T10:45:56.184Z

While resolving: aframe@1.0.3
Found: three@0.133.1
node_modules/three
  three@"github:mozillareality/three.js#hubs-patches-133" from the root project
  peer three@"*" from three-ammo@1.0.12
  node_modules/three-ammo
    three-ammo@"github:infinitelee/three-ammo" from the root project
  peer three@">= 0.123.0" from three-mesh-bvh@0.3.7
  node_modules/three-mesh-bvh
    three-mesh-bvh@"^0.3.7" from the root project
  peer three@"0.x.x" from three-pathfinding@0.14.1
  node_modules/three-pathfinding
    three-pathfinding@"^0.14.1" from the root project
  peer three@"*" from three-to-ammo@1.0.0
  node_modules/three-to-ammo
    three-to-ammo@"github:infinitelee/three-to-ammo" from the root project
  peer three@">=0.103.0" from troika-three-text@0.45.0
  node_modules/troika-three-text
    troika-three-text@"^0.45.0" from the root project
  peer three@">=0.103.0" from troika-three-utils@0.45.0
  node_modules/troika-three-utils
    troika-three-utils@"^0.45.0" from troika-three-text@0.45.0
    node_modules/troika-three-text
      troika-three-text@"^0.45.0" from the root project

Could not resolve dependency:
peer three@"^0.128.0" from aframe@1.0.3
node_modules/aframe
  aframe@"github:mozillareality/aframe#hubs/master" from the root project

Conflicting peer dependency: three@0.128.0
node_modules/three
  peer three@"^0.128.0" from aframe@1.0.3
  node_modules/aframe
    aframe@"github:mozillareality/aframe#hubs/master" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

so I think https://github.com/MozillaReality/aframe/blob/deba2d4eedda664bb7d87bf4b3c9fcf25f5298e1/package.json#L90 should be same with https://github.com/mozilla/hubs/blob/d68d0fd9160997e0f7b4136a9a4e31d0e70c0481/package.json#L135 .

jbshin-gemiso commented 2 years ago

I'm writing this in case it helps. I solved it by doing the following.

  1. Remove the 'easyrtc' dependency.
    • You can modify it directly by referring to the update history, or you can use the latest package-lock.json
    • In my case, I also modified package-lock.json in the admin folder.
  2. Clear npm's cache (using 'npm cache verify' )
  3. The 'node_modules' folder is empty
  4. npm install
demzou commented 2 years ago

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="
            }
          }
        },
  2. 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)

  3. Delete 'node_modules' folder at the root AND in admin

  4. npm install

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

truknbass commented 2 years ago

Following @demzou and @jbshin-gemiso guide, im still having issues. Still getting npm ERR! Invalid Version: 0.5.0a error. Tried removing easyrtc from both admin and root folder package-lock.json, cache clean force and npm install and it still fails.

truknbass commented 2 years ago

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.

jbshin-gemiso commented 2 years ago

@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.

matthewwiese commented 2 years ago

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!

tksham commented 2 years ago

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 commented 2 years ago

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

cherry-fan commented 2 years ago

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