nodeguy/3ab0ccbe.cfaa4de3.js
2020-10-18 14:45:45 +00:00

1 line
6.3 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[99],{157:function(e,n,t){"use strict";t.r(n),t.d(n,"frontMatter",(function(){return a})),t.d(n,"metadata",(function(){return u})),t.d(n,"rightToc",(function(){return l})),t.d(n,"default",(function(){return s}));var o=t(2),r=t(6),i=(t(0),t(431)),a={sidebar_label:"Native Node Modules",title:"Using native Node Modules"},u={unversionedId:"guides/using-native-node-modules",id:"guides/using-native-node-modules",isDocsHomePage:!1,title:"Using native Node Modules",description:"Native Node modules are supported by NodeGui, but since NodeGui is very",source:"@site/docs/guides/using-native-node-modules.md",slug:"/guides/using-native-node-modules",permalink:"/docs/guides/using-native-node-modules",editUrl:"https://github.com/nodegui/nodegui/edit/master/website/docs/guides/using-native-node-modules.md",version:"current",sidebar_label:"Native Node Modules",sidebar:"guides",previous:{title:"Debugging in VSCode",permalink:"/docs/guides/debugging-in-vscode"},next:{title:"Custom NodeGui Plugin",permalink:"/docs/guides/custom-nodegui-native-plugin"}},l=[{value:"How to install native modules",id:"how-to-install-native-modules",children:[]},{value:"Troubleshooting",id:"troubleshooting",children:[]},{value:"Modules that rely on <code>node-pre-gyp</code>",id:"modules-that-rely-on-node-pre-gyp",children:[]}],d={rightToc:l};function s(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(o.a)({},d,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("p",null,"Native Node modules are supported by NodeGui, but since NodeGui is very\nlikely to use a different V8 version from the Node binary installed on your\nsystem, the modules you use will need to be recompiled for NodeGui's node/v8 version. Otherwise,\nyou will get the following class of error when you try to run your app:"),Object(i.b)("pre",null,Object(i.b)("code",Object(o.a)({parentName:"pre"},{className:"language-sh"}),"Error: The module '/path/to/native/module.node'\nwas compiled against a different Node.js version using\nNODE_MODULE_VERSION $XYZ. This version of Node.js requires\nNODE_MODULE_VERSION $ABC. Please try re-compiling or re-installing\nthe module (for instance, using `npm rebuild` or `npm install`).\n")),Object(i.b)("h2",{id:"how-to-install-native-modules"},"How to install native modules"),Object(i.b)("p",null,"To compile native Node modules against a build of NodeGui that doesn't\nmatch a public release, instruct ",Object(i.b)("inlineCode",{parentName:"p"},"npm")," to use the version of Qode (NodeJs) you have bundled\nwith your custom build."),Object(i.b)("pre",null,Object(i.b)("code",Object(o.a)({parentName:"pre"},{className:"language-sh"}),"npm rebuild --nodedir=/path/to/nodegui/vendor/qode\n")),Object(i.b)("p",null,"or"),Object(i.b)("pre",null,Object(i.b)("code",Object(o.a)({parentName:"pre"},{className:"language-sh"}),"qode /path/to/npm rebuild\n")),Object(i.b)("h2",{id:"troubleshooting"},"Troubleshooting"),Object(i.b)("p",null,"If you installed a native module and found it was not working, you need to check\nthe following things:"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"When in doubt, rebuild native modules with qode first."),Object(i.b)("li",{parentName:"ul"},"Make sure the native module is compatible with the target platform and\narchitecture for your NodeGui app."),Object(i.b)("li",{parentName:"ul"},"After you upgrade NodeGui, you usually need to rebuild the modules.")),Object(i.b)("h2",{id:"modules-that-rely-on-node-pre-gyp"},"Modules that rely on ",Object(i.b)("inlineCode",{parentName:"h2"},"node-pre-gyp")),Object(i.b)("p",null,"The ",Object(i.b)("a",Object(o.a)({parentName:"p"},{href:"https://github.com/mapbox/node-pre-gyp"}),Object(i.b)("inlineCode",{parentName:"a"},"node-pre-gyp")," tool")," provides a way to deploy native Node\nmodules with prebuilt binaries, and many popular modules are using it."),Object(i.b)("p",null,"Usually those modules work fine under NodeGui, but sometimes when NodeGui uses\na newer version of V8 than Node and/or there are ABI changes, bad things may\nhappen. So in general, it is recommended to always build native modules from\nsource code."))}s.isMDXComponent=!0},431:function(e,n,t){"use strict";t.d(n,"a",(function(){return c})),t.d(n,"b",(function(){return m}));var o=t(0),r=t.n(o);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function u(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?a(Object(t),!0).forEach((function(n){i(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function l(e,n){if(null==e)return{};var t,o,r=function(e,n){if(null==e)return{};var t,o,r={},i=Object.keys(e);for(o=0;o<i.length;o++)t=i[o],n.indexOf(t)>=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)t=i[o],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var d=r.a.createContext({}),s=function(e){var n=r.a.useContext(d),t=n;return e&&(t="function"==typeof e?e(n):u(u({},n),e)),t},c=function(e){var n=s(e.components);return r.a.createElement(d.Provider,{value:n},e.children)},p={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},b=r.a.forwardRef((function(e,n){var t=e.components,o=e.mdxType,i=e.originalType,a=e.parentName,d=l(e,["components","mdxType","originalType","parentName"]),c=s(t),b=o,m=c["".concat(a,".").concat(b)]||c[b]||p[b]||i;return t?r.a.createElement(m,u(u({ref:n},d),{},{components:t})):r.a.createElement(m,u({ref:n},d))}));function m(e,n){var t=arguments,o=n&&n.mdxType;if("string"==typeof e||o){var i=t.length,a=new Array(i);a[0]=b;var u={};for(var l in n)hasOwnProperty.call(n,l)&&(u[l]=n[l]);u.originalType=e,u.mdxType="string"==typeof e?e:o,a[1]=u;for(var d=2;d<i;d++)a[d]=t[d];return r.a.createElement.apply(null,a)}return r.a.createElement.apply(null,t)}b.displayName="MDXCreateElement"}}]);