Electron uses a native node module.

  node.js, question

Problem

The local node is 4.X and the electron’s is 6.X, which results in the module installed by npm cannot be used on electron.

Try to use electron-rebuild to resolve, but always report an error.

图片描述

Can you be more specific, for example, what bag is it?
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

targetIt’s the version number of electron

Then note that node-sass downloads the compiled binary file by default, so it needs to be re-specified. My method is as follows, not the only one:

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