Yuan Ma
Yuan Ma

Reputation: 868

Can not install older version of Electron through package.json

Since the current VS code doesn't support Electron v1.6, so I have to downgrade my Electron version. However, I found that I can not install the old version of Electron by giving the version number in the package.json file. The following is my configuration:

{
  "name": "Example",
  "version": "1.0.0",
  "description": "",
  "main": "./app/main.js",
  "scripts": {
    "postinstall": "install-app-deps",
    "start": "electron ."
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "electron-builder": "^15.5.1",
    "electron": "^1.4",
    "electron-rebuild": "^1.5.7"
  },
  "dependencies": {
    "jquery": "^3.1.1",
    "sqlite3": "^3.1.8"
  }
}

The output of the npm install is the following:

enter image description here

And I run the following command to check the version of Electron:

node_modules/.bin/electron -v

and the output is '1.6.2' which is the latest version of Electron.

What's more interesting is that I can install the old version of Electron successfully by directly running the following command:

npm install [email protected]

So I want to if there is anything wrong in my package.json file which caused this problem. And if so, how can I fix it.

Upvotes: 4

Views: 5894

Answers (1)

Alexander Leithner
Alexander Leithner

Reputation: 3432

Actually, the Electron version 1.6 satisfies "^1.4" because the caret tells NPM the minimal version of the package to install.

As also written in an answer to the Microsoft issue on GitHub, you might use "1.4" or "~1.4.0" in order to get Electron 1.4 or any other 1.4.x version (the tilde is for minimal minor releases as shown in the NPM documentation for the cli-based update of packages).

Upvotes: 4

Related Questions