node.js - electron使用原生node模块
天蓬老师
天蓬老师 2017-04-17 15:32:43
0
2
700

问题

本地node是4.X,electron的是6.X,导致npm安装的模块不能在electron上使用

尝试使用electron-rebuild解决,但一直报错

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
PHPzhong

Can you give me more details, for example, what kind of bag is it packed in?
This is my plan, you can try it:

node-gyp --target=1.3.5 --runtime=electron --fallback-to-build --directory ./node_modules/node-sass --dist-url=https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist configure
node-gyp --target=1.3.5 --runtime=electron --fallback-to-build --directory ./node_modules/node-sass --dist-url=https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist  rebuild

target is the version number of electron

Then please note that node-sass downloads the compiled binary file by default, so you need to re-specify it. My method is as follows, which is not the only one:

process.env.SASS_BINARY_PATH = path.join(__dirname, './node_modules/node-sass/build/Release/binding.node');
Peter_Zhu

One thing you need to know is to switch the node version directly. The modules installed by node_modules are 无法使用.
The node_model installed in node4.x cannot be used normally if you switch to version 6.x and needs to be 删掉restartednpm install.
So I suggest you upgrade your local machine to 6.x, install the module and then package the application (nvm can help you manage the installation switching of multiple node versions).

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template