Electron-builder: Module version mismatch. Expected 48, got 47.

Created on 31 May 2016  Â·  11Comments  Â·  Source: electron-userland/electron-builder

I'm working on a project that often runs hot and cold. As it happens, I haven't run a build in a little over a month (it's been a cold period). At the time, it worked just fine. Today, though, I tried to run a build and got this:

Module version mismatch. Expected 48, got 47.

In my project root, I have the following package.json:

{
  "name": "status-meter",
  "productName": "Status Meter",
  "description": "Status Meter is like a fuel gauge for your data allowance.",
  "homepage": "http://services.myclient.com/statusmeter",
  "repository": {
    "type": "git",
    "url": "https://bitbucket.org/owner/repo"
  },
  "dependencies": {
    "aws-sdk": "^2.2.15",
    "electron-builder": "^2.11.0",
    "electron-packager": "^6.0.2",
    "electron-prebuilt": "^0.36.0"
  },
  "scripts": {
    "clean": "rm -rf dist",
    "clean:osx": "rm -rf dist/osx",
    "clean:win": "rm -rf dist/win",
    "build": "npm run clean && npm run build:osx && npm run build:win",
    "build:osx": "npm run clean:osx && electron-packager ./app \"Status Meter\" --ignore=node_modules/.bin --out=dist/osx/ --platform=darwin --arch=x64 --version=0.36.12 --icon=\"build/assets/osx/Status Meter.icns\" --prune --app-bundle-id=\"com.myclient.statusmeter\" --app-version=$(node -e 'console.log(require(\"./app/package.json\").version)')",
    "build:win": "npm run clean:win && electron-packager ./app \"Status Meter\" --ignore=node_modules/.bin --out=dist/win/ --platform=win32 --arch=ia32 --version=0.36.12 --icon=\"build/assets/win/Status Meter.ico\" --prune --app-version=$(node -e 'console.log(require(\"./app/package.json\").version)')",
    "pack": "npm run pack:osx && npm run pack:win",
    "pack:osx": "npm run build:osx && electron-builder \"dist/osx/Status Meter-darwin-x64/Status Meter.app\" --platform=osx --out=dist/osx/ --config=build/config.json",
    "pack:win": "npm run build:win && electron-builder \"dist/win/Status Meter-win32-ia32\" --platform=win --out=dist/win/ --config=build/config.json",
    "nightly": "npm run pack && node bin/upload.js"
  }
}

I run the build by simply executing

$ npm run nightly

Locally, I'm running Node v6.0.0.

My issue seems similar to #39, but I'm not certain of that. I've been looking around for a map of electron version to the packaged node version, but haven't found one yet. Any advice would be a big help.

question

Most helpful comment

1) Remove node_modules directory completely (rm -rf node_modules).
2) Please ensure that you don't use sudo.
3) npm install.

All 11 comments

1) Remove node_modules directory completely (rm -rf node_modules).
2) Please ensure that you don't use sudo.
3) npm install.

Locally, I'm running Node v6.0.0.

Please update to node 6.2.0. and npm install npm -g

@develar Thanks for your help. That seems to have done the trick, but I have to confess that I'm not sure why. I can't think of anything that should've changed (locally) since I last ran things. Would you mind taking a minute to explain what you clearly knew would change so I'll be more educated the next time around?

Would you mind taking a minute to explain what you clearly knew

Well, npm is not reliable and buggy. So, it is like a windows — if something goes wrong, first step is to reboot machine (i.e. remove cache and old node_modules) :)

@develar 😀 Fair enough. Thanks again.

After spending a day on this I figured out the answer. If all else fails you need to install your packages and then run _npm rebuild --runtime=electron --target=1.3.4 --disturl=https://atom.io/download/atom-shell --abi=49_

where 1.3.4 is your electron version and 49 is the abi it's expecting.

@TomAshley303 Please see #683

@TomAshley303 work for me, npm rebuild --runtime=electron --target=[electron version] --disturl=https://atom.io/download/atom-shell --abi=[expected module version] , Thanks

The only solution working for me was with this command:
"npm install electron --save-dev"

Once added, my app works with "npm start" and after packing. Also notice that I'm using windows.

See ya!

Thanks a lot @develar

(Windows users) You can manage your node version with node version manager:
https://github.com/coreybutler/nvm-windows

Was this page helpful?
0 / 5 - 0 ratings

Related issues

philcockfield picture philcockfield  Â·  3Comments

popod picture popod  Â·  3Comments

jhg picture jhg  Â·  3Comments

alexstrat picture alexstrat  Â·  3Comments

mstralka picture mstralka  Â·  3Comments