Skip to content

Hoisting Electron with Yarn workspaces breaks Electron #4070

@robdonn

Description

@robdonn

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
When working in a monorepo using Yarn workspaces and the dependencies for an electron app are hoisted to root, when you run lerna bootstrap the electron app is no longer operable from the scripts in package.json

"start": "electron ."

Error

throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')

Directory

apps
- desktop/electron (app-desktop)
-- index.html
-- index.js
-- package.json
packages
- components
-- component 1 (component-one)
--- index.js
--- package.json
-- component 2 (component-two)
--- index.js
--- package.json
lerna.json
package.json

lerna.json

{
  "lerna": "2.0.0",
  "version": "0.0.2",
  "npmClient": "yarn",
  "useWorkspaces": true,
  "commands": {
    "publish": {
      "ignore": "app-*"
    }
  }
}

root package.json

{
  "name": "root",
  "version": "0.0.1",
  "description": "Monorepo",
  "private": true,
  "workspaces": [
    "packages/components/*",
    "apps/*"
  ],
  "devDependencies": {
    "lerna": "^2.0.0"
  }
}

Desktop/Electron app package.json

{
  "name": "app-desktop",
  "version": "0.0.1",
  "description": "Desktop app",
  "main": "index.js",
  "scripts": {
    "start": "electron ."
  },
  "dependencies": {
    "react": "^15.6.1",
    "react-dom": "^15.6.1"
  },
  "devDependencies": {
    "component-one": "^0.0.2",
    "component-two": "^0.0.2",
    "electron": "^1.6.11",
    "electron-compile": "^6.4.1",
    "electron-prebuilt-compile": "^1.6.11"
  }
}

If the current behavior is a bug, please provide the steps to reproduce.
Sample repo & instructions

What is the expected behavior?
Running yarn start should trigger electron app to launch.

Please mention your node.js, yarn and operating system version.
Node.js -v : 8.2.1
yarn -v : 0.27.5_1
OS -v : macOS Sierra v10.12.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions