Npm install fails due to package.json misconfiguration

Since the commit, running npm install fails.

Looking at the log file …

880 silly fetchPackageMetaData error for jquery.autoellipsis@git+ premature close
881 silly fetchPackageMetaData error for favcount@git+ premature close
882 silly fetchPackageMetaData error for jquery-resize@git+ premature close

… installation fails for dependencies whose version is a git repository instead of a semantic version string. In particular, they fail if in the repostitory, there is no package.json file.

Discourse’s dependencies from package.json:

"dependencies": {
  "ace-builds": "1.4.1",
  "bootbox": "3.2.0",
  "chart.js": "2.7.2",
  "favcount": "",
  "handlebars": "4.0.5",
  "htmlparser": "",
  "jquery": "3.3.1",
  "jquery-color": "1.0.0",
  "jquery-resize": "",
  "jquery.autoellipsis": "",
  "jquery.cookie": "1.4.1",
  "jquery-tags-input": "1.3.5",
  "magnific-popup": "1.1.0",
  "markdown-it": "8.4.1",
  "mousetrap": "",
  "pikaday": "1.7.0",
  "resumablejs": "1.1.0",
  "spectrum-colorpicker": "1.8.0"

Is npm install still supposed to work or is Yarn the only option here?

1 Like

This is a development question, not an install question, yes?

Is it? I wasn’t quite sure. Are these dependencies only relevant for Discourse’s testing? Then the category was wrong indeed. Sorry about that.

1 Like

@pmusaraj any tips here? Also … why are you using npm, we only really test using yarn and only support yarn for dev.

I think the error you’re getting is due to our package.json using yarn syntax for referencing Github versions of dependencies. So, use yarn install instead of npm. Also, yarn install is only required for running frontend (qunit) tests or when a developer is upgrading one of the Discourse dependencies listed in package.json.


I wonder if there is some entry we can add to our package.json that would force npm install to explode with a “sorry, npm is not supported use yarn”

Ultra low priority though.


@pmusaraj that seems like a good track to follow:


I did not know that only Yarn is supposed to be used here. I saw a package.json and run npm install a short while ago to run my plugin tests. Now, npm install doesn’t work.

It looks like Yarn and NPM use incompatible syntax for referencing remote git repositories via URL so there is no nice common ground.
Yarn does seem to support this as per git+ssh install protocol is not used correctly · Issue #2500 · yarnpkg/yarn · GitHub

However, the missing package.json in these repositories makes npm fail.

@kleinfreund there is absolutely no need to run npm install. And as Sam and Joffrey point out, we will shortly block running npm install on the repo. (Just use yarn install.)


I get it. It’s just that I didn’t previously need Yarn, so I have to install it. That’s not a big deal though.

1 Like

This commit adds a preinstall hook that stops npm install and outputs “NPM is not supported, please use Yarn instead.” to the user.