Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS X: Error: Module version mismatch. Expected 48, got 49 #683

Closed
just-jeb opened this issue Aug 20, 2016 · 21 comments · May be fixed by qcif/data-curator#563
Closed

OS X: Error: Module version mismatch. Expected 48, got 49 #683

just-jeb opened this issue Aug 20, 2016 · 21 comments · May be fixed by qcif/data-curator#563
Labels

Comments

@just-jeb
Copy link
Contributor

@just-jeb just-jeb commented Aug 20, 2016

  • ^5.30.0:
  • 1.3.3:

When trying to build for OS X getting the following error:
tsc && node-gyp rebuild && build --mac

Error: Module version mismatch. Expected 48, got 49.
at Error (native)
at Object.Module._extensions..node (module.js:583:18)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object. (/Users/Jenia/Desktop/git/electron-angular2-native/node_modules/macos-alias/lib/create.js:7:13)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object. (/Users/Jenia/Desktop/git/electron-angular2-native/node_modules/macos-alias/index.js:1:18)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object. (/Users/Jenia/Desktop/git/electron-angular2-native/node_modules/ds-store/index.js:2:13)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
From previous event:
at tsAwaiter (/Users/Jenia/Desktop/git/electron-angular2-native/node_modules/electron-builder/src/util/awaiter.ts:10:47)
at Object.build (/Users/Jenia/Desktop/git/electron-angular2-native/node_modules/electron-builder/src/builder.ts:195:52)
at Object. (/Users/Jenia/Desktop/git/electron-angular2-native/node_modules/electron-builder/src/build-cli.ts:27:28)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3

To reproduce:

@develar
Copy link
Member

@develar develar commented Aug 20, 2016

Duplicates #453 (comment)

@develar develar closed this Aug 20, 2016
@develar develar added the duplicate label Aug 20, 2016
@just-jeb
Copy link
Contributor Author

@just-jeb just-jeb commented Aug 20, 2016

Tried removing node_modules + npm cache clean + npm install. Won't help. Running node 6.4.0.

@develar develar reopened this Aug 20, 2016
@develar
Copy link
Member

@develar develar commented Aug 20, 2016

Please do not node-gyp rebuild — it is not correct — electron headers must be used. If you have native deps, use 2 package.json structure and electron-builder will compile it for you automatically.

@develar
Copy link
Member

@develar develar commented Aug 20, 2016

I see that you are author of this boilerplate project, may be https://github.com/szwacz/electron-boilerplate will be useful for you.

@just-jeb
Copy link
Contributor Author

@just-jeb just-jeb commented Aug 20, 2016

I am using 2 package.json structure, and I have to do node-gyp rebuild as
I have native modules as a part of the project (not just external
dependency).
But this is not the issue, I'm pretty convinced so. I do use electron
headers (see .npmrc in the root of the project), and it also works with
no problems on Windows and Linux. The problem only appears on OS X.

The boilerplate you mentioned does not have any native module in it, so it's not my case.

@just-jeb
Copy link
Contributor Author

@just-jeb just-jeb commented Aug 20, 2016

Also, I am able to run it on OS X (npm start), what fails is only the build.

@develar
Copy link
Member

@develar develar commented Aug 20, 2016

Ok, I will investigate.

@develar develar added investigate and removed duplicate labels Aug 20, 2016
@develar
Copy link
Member

@develar develar commented Aug 20, 2016

@just-jeb
Copy link
Contributor Author

@just-jeb just-jeb commented Aug 20, 2016

I'm not sure this is correct. I use the following in my root binding.gyp for specifying which dependencies to compile:

'dependencies': [ 
                '<!@(find ./app/* -name binding.gyp -not -path \"./**/node_modules/*\" | sed -e s/$/:*/)'
            ]

As you can see it skips all the node_modules folders. Since node-gyp rebuild looks for the binding.gyp in the directory it was called from, I can't see how node-gyp rebuild invocation would build the macos-alias.

@develar develar added the wontfix label Aug 20, 2016
@develar
Copy link
Member

@develar develar commented Aug 20, 2016

Sorry, it cannot be fixed. On macOS electron-builder uses some native deps. When you have file .npmrc in your project, it means that npm install will compile native modules according to this configuration. But then you execute build and node trying to use such native modules, but cannot, because it is compiled for electron, not for node.

@develar develar closed this Aug 20, 2016
@develar
Copy link
Member

@develar develar commented Aug 20, 2016

I will investigate is it possible to remove such native deps (macos-alias as dep of appdmg).

@develar
Copy link
Member

@develar develar commented Aug 20, 2016

I think, as solution, electron-builder can provide some script to perform node-gyp rebuild task.

@just-jeb
Copy link
Contributor Author

@just-jeb just-jeb commented Aug 20, 2016

Ok, let me see if I got this right.
The problem is that I'm specifying headers by exporting variables (and not by passing it to node-gyp rebuild, for example).
Since I export the variables, it applies to all the native modules, including some electron-builder dependecies (macos-alias). Then node tries to use electron-builder and fails because some of its dependencies were built with another version (electrons) of headers.
Is that correct?
If so, the simplest solution (on my side) will be passing the arguments to node-gyp rebuild from the command line, instead of .npmrc file.
How electron-builder providing a script to perform node-gyp rebuild will help?

@develar
Copy link
Member

@develar develar commented Aug 20, 2016

How electron-builder providing a script to perform node-gyp rebuild will help?

Option nodeGypRebuild will be added in 10 minutes. You just set it to true and electron-builder will call it for you with proper env/conf.

@develar develar closed this in 6d433ad Aug 20, 2016
@develar
Copy link
Member

@develar develar commented Aug 20, 2016

Set "nodeGypRebuild": true in your build and remove .npmrc file.

@develar develar added the feature label Aug 20, 2016
@just-jeb
Copy link
Contributor Author

@just-jeb just-jeb commented Aug 22, 2016

Well, it indeed solves the problem, kudos for the solution.
It does introduce a new problem though. When I had .npmrc file, the node-gyp rebuild (which occurred on npm install or by demand) was compiling my own native addons with electron headers.
So I was able to run and debug the application without packaging it. Now I cannot do this, because the native addons compile with node headers.
The only way to run the application is running a build step first.
I can run node-gyp rebuild explicitly while specifying electron headers and target, but in this case this whole solution becomes redundant.
Thoughts?

@develar
Copy link
Member

@develar develar commented Aug 22, 2016

node-gyp-rebuild bin will be added.

@just-jeb
Copy link
Contributor Author

@just-jeb just-jeb commented Aug 22, 2016

Great. Btw, perhaps you should add to the documentation clarification about .npmrc affecting the build.

@develar
Copy link
Member

@develar develar commented Aug 22, 2016

@meltedspark PR to improve doc welcome :)

develar added a commit that referenced this issue Aug 22, 2016
just-jeb pushed a commit to just-jeb/electron-angular-native that referenced this issue Aug 22, 2016
develar added a commit that referenced this issue Aug 22, 2016
Add clarification regarding how native addons that are not dependencies but a part of the project should be treated

#683
@zaggino
Copy link

@zaggino zaggino commented Aug 24, 2016

@develar same error here, repo https://github.com/zaggino/brackets-electron and build here https://travis-ci.org/zaggino/brackets-electron ... linux is passing, osx is not with Module version mismatch. Expected 48, got 49. There're no node-gyp references in the project or npmrc file. Can you advise?

@songlineboy
Copy link

@songlineboy songlineboy commented Sep 12, 2018

How are you running the process?

If it might help anyone, we had a similar issues running node via pm2, we were getting this error: Error: Module version mismatch. Expected 48, got 57

It seems the number refers to NODE MODULE version, 48 is node 6, 57 is node 8.

We were running our pm2 processes and each process specifies a particular node version to use. They were point to node 6 versions, even thought our current nvm use version was at 8.12. (node.js version 8.12.0 )

Deleting and restarting the PM2 jobs, created the tasks with the updated link to node 8.12 and we stopped getting that error.

Hope it helps someone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.