{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node-addon-api/issues/269","repository_url":"https://api.github.com/repos/nodejs/node-addon-api","labels_url":"https://api.github.com/repos/nodejs/node-addon-api/issues/269/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node-addon-api/issues/269/comments","events_url":"https://api.github.com/repos/nodejs/node-addon-api/issues/269/events","html_url":"https://github.com/nodejs/node-addon-api/issues/269","id":322903982,"node_id":"MDU6SXNzdWUzMjI5MDM5ODI=","number":269,"title":"N-api builds not cross runtime with Electron on windows","user":{"login":"jpkolbush","id":17112993,"node_id":"MDQ6VXNlcjE3MTEyOTkz","avatar_url":"https://avatars3.githubusercontent.com/u/17112993?v=4","gravatar_id":"","url":"https://api.github.com/users/jpkolbush","html_url":"https://github.com/jpkolbush","followers_url":"https://api.github.com/users/jpkolbush/followers","following_url":"https://api.github.com/users/jpkolbush/following{/other_user}","gists_url":"https://api.github.com/users/jpkolbush/gists{/gist_id}","starred_url":"https://api.github.com/users/jpkolbush/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpkolbush/subscriptions","organizations_url":"https://api.github.com/users/jpkolbush/orgs","repos_url":"https://api.github.com/users/jpkolbush/repos","events_url":"https://api.github.com/users/jpkolbush/events{/privacy}","received_events_url":"https://api.github.com/users/jpkolbush/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":20,"created_at":"2018-05-14T17:09:31Z","updated_at":"2019-03-29T16:39:11Z","closed_at":null,"author_association":"NONE","body":"* **Node Version**: 8.9.4\r\n* **Platform**: Windows\r\n* **Compiler**: MSVC 15\r\n\r\n\r\nI was led to believe that the new n-api was not only going to be compatible across all node runtimes, but also going to be compatible when building a native module for node vs building for electron. \r\nIf you build the basic hello-world example for n-api found [here](https://nodejs.org/api/addons.html#addons_n_api), the `addon.node` file cannot be required when running from the electron runtime. I get the following error:\r\n\r\n```\r\nA dynamic link library (DLL) initialization routine failed.\r\n\\\\?\\C:\\Users\\kelannen\\source\\napi-test\\build\\Release\\addon.node\r\nError: A dynamic link library (DLL) initialization routine failed.\r\n\\\\?\\C:\\Users\\kelannen\\source\\napi-test\\build\\Release\\addon.node\r\n    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)\r\n    at Object.Module._extensions..node (module.js:671:18)\r\n    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)\r\n    at Module.load (module.js:561:32)\r\n    at tryModuleLoad (module.js:504:12)\r\n    at Function.Module._load (module.js:496:3)\r\n    at Module.require (module.js:586:17)\r\n    at require (internal/module.js:11:18)\r\n    at Object.<anonymous> (C:\\Users\\kelannen\\source\\napi-test\\test.js:2:15)\r\n    at Object.<anonymous> (C:\\Users\\kelannen\\source\\napi-test\\test.js:6:3)\r\n    at Module._compile (module.js:642:30)\r\n    at Object.Module._extensions..js (module.js:653:10)\r\n    at Module.load (module.js:561:32)\r\n    at tryModuleLoad (module.js:504:12)\r\n    at Function.Module._load (module.js:496:3)\r\n    at Module.require (module.js:586:17)\r\n    at require (internal/module.js:11:18)\r\n    at C:\\Users\\kelannen\\source\\napi-test\\node_modules\\mocha\\lib\\mocha.js:253:27\r\n    at Array.forEach (<anonymous>)\r\n    at Mocha.loadFiles (C:\\Users\\kelannen\\source\\napi-test\\node_modules\\mocha\\lib\\mocha.js:250:14)\r\n    at Mocha.run (C:\\Users\\kelannen\\source\\napi-test\\node_modules\\mocha\\lib\\mocha.js:577:10)\r\n    at Object.run (C:\\Users\\kelannen\\source\\napi-test\\node_modules\\electron-mocha\\mocha.js:54:30)\r\n    at App.app.on (C:\\Users\\kelannen\\source\\napi-test\\node_modules\\electron-mocha\\index.js:54:13)\r\n    at emitTwo (events.js:131:20)\r\n    at App.emit (events.js:214:7)\r\n```\r\n\r\nI set up a basic test here:\r\n\r\nhttps://github.com/jpkolbush/napi-test\r\n\r\nSteps to reproduce:\r\n```\r\nnpm install\r\n\r\n#runs node-gyp configure-build\r\nnpm run build\r\n\r\n#confirms that the module can be included with node runtime\r\nnode test.js\r\n\r\n#requires the node module while running electron-mocha, this command will fail\r\nnpm run electron-test\r\n```\r\n\r\nThis is only an issue on Windows, does not appear on Unix.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/nodejs/node-addon-api/issues/comments/478066591","html_url":"https://github.com/nodejs/node-addon-api/issues/269#issuecomment-478066591","issue_url":"https://api.github.com/repos/nodejs/node-addon-api/issues/269","id":478066591,"node_id":"MDEyOklzc3VlQ29tbWVudDQ3ODA2NjU5MQ==","user":{"login":"gabrielschulhof","id":976081,"node_id":"MDQ6VXNlcjk3NjA4MQ==","avatar_url":"https://avatars2.githubusercontent.com/u/976081?v=4","gravatar_id":"","url":"https://api.github.com/users/gabrielschulhof","html_url":"https://github.com/gabrielschulhof","followers_url":"https://api.github.com/users/gabrielschulhof/followers","following_url":"https://api.github.com/users/gabrielschulhof/following{/other_user}","gists_url":"https://api.github.com/users/gabrielschulhof/gists{/gist_id}","starred_url":"https://api.github.com/users/gabrielschulhof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabrielschulhof/subscriptions","organizations_url":"https://api.github.com/users/gabrielschulhof/orgs","repos_url":"https://api.github.com/users/gabrielschulhof/repos","events_url":"https://api.github.com/users/gabrielschulhof/events{/privacy}","received_events_url":"https://api.github.com/users/gabrielschulhof/received_events","type":"User","site_admin":false},"created_at":"2019-03-29T16:39:11Z","updated_at":"2019-03-29T16:39:11Z","author_association":"CONTRIBUTOR","body":"@vweevers I'm pretty sure it's Windows-specific, because on Windows the source of the symbols required by the native addon matters. If the native addon specifies that the symbols have to come from \"node.exe\", then the loader will only use \"node.exe\" to resolve the symbols. \"node.dll\" will not satisfy the requirement. However, the [workaround](https://github.com/nodejs/node-addon-api/issues/269#issuecomment-455580129) above presented by @stevebaxter should do the trick."}}
{"actor":{"display_login":"gabrielschulhof"}}