node.js - electron使用原生node模块
问题描述
问题本地node是4.X,electron的是6.X,导致npm安装的模块不能在electron上使用
尝试使用electron-rebuild解决,但一直报错

问题解答
回答1:能说得详细点么,比如说装的是什么包?这是我的方案,你可以试试:
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 是electron的版本号
然后注意node-sass 默认下载已编译好的二进制文件,所以需要重新指定,我的办法如下,不唯一:
process.env.SASS_BINARY_PATH = path.join(__dirname, ’./node_modules/node-sass/build/Release/binding.node’);回答2:
有一点你需要知道,直接切换node版本,node_modules安装的模块是无法使用的。node4.x装的node_model,切换6.x版本无法正常使用,需要删掉重新npm install。所以我建议你把本地升级到6.x,安装模块再打包应用程序(nvm可以帮你管理多个node版本的安装切换)。
相关文章:
1. celery+redis 怎么看redis里面的内容2. 为什么redis中incr一个“0” 会报错?3. javascript - 最近用echarts做统计图时遇到两个问题!!4. android - TextInputLayout的空白显示问题5. android - 优酷的安卓及苹果app还在使用flash技术吗?6. android - 百度地图拖拽图标后原来位置的图标还在?7. css内联样式的style8. mysql - 我的myeclipse一直连显示数据库连接失败,不知道为什么9. 微信$data =file_get_contents(’php://input’)取不到数据,抓包10. css - input中transition 设置background-color过渡,chrome浏览器页面初始化渲染会有过度效果

网公网安备