fsevents: Cannot install fsevents with Electron as runtime
Using latest fsevents that brings node-pre-gyp I am no longer able to install this dependency (via chokidar) into VS Code that leverages Electron as framework.
Our npm script for installation configures some environment variables to pick up the correct headers for the embedded node.js version within Electron:
npm_config_disturl=https://atom.io/download/atom-shell \
npm_config_target=$ELECTRON_VERSION \
Running this via npm install yields:
> fsevents@1.0.12 install /Users/bpasero/Development/monaco/node_modules/fsevents
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! install error 
node-pre-gyp ERR! stack Error: Unsupported target version: 0.37.6
node-pre-gyp ERR! stack     at get_runtime_abi (/Users/bpasero/Development/monaco/node_modules/node-pre-gyp/lib/util/versioning.js:156:23)
node-pre-gyp ERR! stack     at Object.module.exports.evaluate (/Users/bpasero/Development/monaco/node_modules/node-pre-gyp/lib/util/versioning.js:277:19)
node-pre-gyp ERR! stack     at install (/Users/bpasero/Development/monaco/node_modules/node-pre-gyp/lib/install.js:138:31)
node-pre-gyp ERR! stack     at Object.self.commands.(anonymous function) [as install] (/Users/bpasero/Development/monaco/node_modules/node-pre-gyp/lib/node-pre-gyp.js:48:37)
node-pre-gyp ERR! stack     at run (/Users/bpasero/Development/monaco/node_modules/node-pre-gyp/bin/node-pre-gyp:79:30)
node-pre-gyp ERR! stack     at Object.<anonymous> (/Users/bpasero/Development/monaco/node_modules/node-pre-gyp/bin/node-pre-gyp:131:1)
node-pre-gyp ERR! stack     at Module._compile (module.js:413:34)
node-pre-gyp ERR! stack     at Object.Module._extensions..js (module.js:422:10)
node-pre-gyp ERR! stack     at Module.load (module.js:357:32)
node-pre-gyp ERR! stack     at Function.Module._load (module.js:314:12)
node-pre-gyp ERR! System Darwin 15.4.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/bpasero/Development/monaco/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/bpasero/Development/monaco/node_modules/fsevents
node-pre-gyp ERR! node -v v5.10.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.27
node-pre-gyp ERR! not ok 
Unsupported target version: 0.37.6
npm WARN install:fsevents@1.0.12 fsevents@1.0.12 install: `node-pre-gyp install --fallback-to-build`
npm WARN install:fsevents@1.0.12 Exit status 1
This basically means we cannot update to newer versions of chokidar currently.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 22 (10 by maintainers)
Commits related to this issue
- ibmdb: Workaround fsevents install with electron * See https://github.com/strongloop/fsevents/issues/131 — committed to n-riesco/plotly-database-connector by n-riesco 7 years ago
I’ve spent hours sorting this out, and it’s pretty simple once you get it. In
package.json:In webpack main process build, you need this to prevent webpack from trying to resolve dependencies in a way that doesn’t make sense in an Electron runtime context. You do this by declaring fsevents as external:
This will not only remove “Critical dependency: the request of a dependency is an expression” warnings you might get so far, but it will also ensure that fsevents is imported with a simple…
require('fsevents')at run time.Of course, fsevents must be natively compiled and embedded in Electron.
electron-rebuild -fsimply does the trick, but I’ve found useful to launch it like this:DEBUG=* electron-rebuild -f… in order to figure out what’s really going on.Hope it helps someone !
I’m reasonably sure
export npm_config_runtime=electronshould do it.