首页 > 解决方案 > 错误:使用 Parcel 运行 Cypress 时找不到绑定文件

问题描述

当我跑步时,cypress run --browser chrome我得到:

The function exported by the plugins file threw an error.

We invoked the function exported by `C:\Users\LFOLMERT\projects\FE\signup\cypress\plugins\index.js`, but it threw an error.

 Error: Could not locate the bindings file. Tried:
 → C:\Users\LFOLMERT\projects\FE\signup\node_modules\deasync\build\deasync.node
 (...stack trace...)
    at tryModuleLoad (module.js:466:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

为了修复它,我尝试了以下命令:

npm rebuild
yarn install --force
npm rebuild --update-binary
rm -rf node_modules && yarn install
rm -rf node_modules && npm install bindings && npm install
cd ./node_modules/deasync && node-gyp rebuild
./node_modules/.bin/electron-rebuild

他们都没有帮助,node-gyp 在deasync/build目录中产生了一些东西,但再次运行 cypress 只会导致不同的错误。运行electron-rebuild正在删除构建的文件。

我在 package.json 中的依赖项:

{
  "dependencies": {
    "babel": "^6.23.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
    "babel-register": "^6.26.0",
    "bindings": "^1.5.0",
    "chai": "^4.2.0",
    "cross-env": "^5.2.0",
    "cypress": "^3.2.0",
    "cypress-failed-log": "^2.4.2",
    "cypress-parcel-preprocessor": "^1.0.0",
    "electron-builder": "^20.39.0",
    "electron-prebuilt": "^1.4.13",
    "electron-rebuild": "^1.8.4",
    "node-gyp": "^3.8.0",
    "parcel-bundler": "^1.12.3"
  },
}

我的柏树/插件/index.js:

module.exports = (on) => {
    on('task', {
        failed: require('cypress-failed-log/src/failed')(),
    });

    on('file', {
        preprocessor: require('cypress-parcel-preprocessor')(),
    });
};

标签: javascriptnode.jscypressnode-gypparceljs

解决方案


推荐阅读