electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.44k stars 511 forks source link

start won't run on Windows, missing electron-to-chromium #193

Closed Flaise closed 7 years ago

Flaise commented 7 years ago

A fresh install of electron-forge appears to compile but not run. All it does is create a dialog box containing a stack trace, which is duplicated in the console. Here's the console output:

>electron-forge start
√ Checking your system
√ Locating Application
√ Preparing native dependencies
√ Launching Application

App threw an error during load
Error: Cannot find module 'electron-to-chromium' (While processing preset: "...\\node_modules\\babel-preset-env\\lib\\index.js")
    at Module._resolveFilename (module.js:455:15)
    at Function.Module._resolveFilename (...\node_modules\electron-prebuilt-compile\node_modules\electron\dist\resources\electron.asar\common\reset-search-paths.js:35:12)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (...\node_modules\babel-preset-env\lib\normalize-options.js:11:27)
    at Module._compile (module.js:556:32)
    at Object.require.extensions.(anonymous function) [as .js] (...\node_modules\electron-compile\lib\require-hook.js:75:14)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)

I'm using: electron-forge 2.9.0 Windows 10 x64 Node 6.10.1

malept commented 7 years ago

Could you run npm install in the Electron app project and then try again? electron-to-chromium should be installed. (It's a dependency of browserslist which is a dependency of babel-preset-env.) You can check by running npm list and checking the output for electron-to-chromium.

MarshallOfSound commented 7 years ago

@Flaise I tried to reproduce this error on Windows/macOS and couldn't get the error occurring on either. Try what @malept said and we'll go from there.

Flaise commented 7 years ago

I deleted my node_modules folder and ran npm install. It failed with the following output:

npm ERR! path ...\node_modules\.staging\assert-plus-e6d248ff\package.json.2984500249
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename '...\node_modules\.staging\assert-plus-e6d248ff\package.json.2984500249' -> '...\node_modules\.staging\assert-plus-e6d248ff\package.json'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, rename '...\node_modules\.staging\assert-plus-e6d248ff\package.json.2984500249' -> '...\node_modules\.staging\assert-plus-e6d248ff\package.json'
npm ERR!     at Error (native)
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: '...\\node_modules\\.staging\\assert-plus-e6d248ff\\package.json.2984500249',
npm ERR!   dest: '...\\node_modules\\.staging\\assert-plus-e6d248ff\\package.json',
npm ERR!   parent: 'sshpk' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

Then I ran npm install again without doing anything else and it mysteriously worked that time. Then I ran electron-forge start and it gave me the same output as before. It said it couldn't find electron-to-chromium so I installed it manually.

>npm install --save electron-to-chromium
+-- babel-preset-env@1.2.2
| +-- browserslist@1.7.7
| | `-- electron-to-chromium@1.3.2  deduped
| `-- electron-to-chromium@1.3.2  deduped
`-- electron-to-chromium@1.3.2

I'm pretty sure that output means it was already installed. Running electron-forge start again gave me the same output again.

My project is working fine on my Mac but since my target audience uses mostly Windows, I need it to work on Windows too.

MarshallOfSound commented 7 years ago

@Flaise What npm version are you using?

Flaise commented 7 years ago

@MarshallOfSound 4.4.4

MarshallOfSound commented 7 years ago

@Flaise Can you try dropping down to npm 3, quite possibly an issue with its "deduping" logic.

Flaise commented 7 years ago

@MarshallOfSound npm version is now 3.10.10. I uninstalled and reinstalled electron-forge, deleted the node_modules folder, and npm installed all over again. I get the same result out of electron-forge start.

MarshallOfSound commented 7 years ago

@Flaise I think in this process your app just gotten a bit screwed up 😢 Can you try a complete reset.

npm uninstall -g electron-forge
npm i -g electron-forge
electron-forge init test
cd test
electron-forge start
malept commented 7 years ago

Yeah, I agree with @MarshallOfSound. it's quite strange that your babel-preset-env is at 1.2.2.

Flaise commented 7 years ago

@malept I altered that dependency because of issue #186.

Here's what I tried this time: First I created the new test project from scratch as instructed. It worked on the first try with no errors. Then I made the dependencies that the new test project and the project that I'm troubleshooting have in common look the same. The package.json file that I'm troubleshooting now contains:

  "dependencies": {
    "babel-runtime": "^5.8.25",
    "electron-compile": "^6.2.0",
    "electron-window-state": "^4.0.2",
    "skid": "0.0.4",
    "vue": "^2.2.1"
  },
  "devDependencies": {
    "babel-plugin-transform-async-to-generator": "^6.22.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-react": "^6.23.0",
    "electron-prebuilt-compile": "1.6.2",
    "eslint": "^3.19.0",
    "eslint-config-airbnb": "^14.1.0",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "^3.0.2",
    "eslint-plugin-react": "^6.10.3"
  }

Aside from the irrelevant dependencies like Skid, the dependencies and devDependencies sections of each package.json file are the same. Then I deleted the node_modules folder and reinstalled everything and ran the project again. Here's the output:

App threw an error during load
Error: Target version must be a number,
          '1.4.15' was given for 'electron' (While processing preset: "...\\node_modules\\babel-preset-env\\lib\\index.js")
    at ...\node_modules\babel-preset-env\lib\index.js:64:13
    at Array.filter (native)
    at isPluginRequired (...\node_modules\babel-preset-env\lib\index.js:54:54)
    at filterItem (...\node_modules\babel-preset-env\lib\index.js:166:20)
    at Array.filter (native)
    at buildPreset (...\node_modules\babel-preset-env\lib\index.js:215:56)
    at ...\node_modules\babel-core\lib\transformation\file\options\option-manager.js:317:46
    at Array.map (native)
    at OptionManager.resolvePresets (...\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
    at OptionManager.mergePresets (...\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)

It looks almost like issue #186 except that my copy of the software is asking me for version '1.4.15' where the other person's dependency was '1.6.0', neither of which matches the "electron-prebuilt-compile": "1.6.2" entry in my package.json file.

malept commented 7 years ago

Are you creating a new project with the vue template?

MarshallOfSound commented 7 years ago

@Flaise Go to your .compilerc and change all instances of the string electron version "1.4.15" to be a number 1.6.

Also, yeah, are you using the vue template?

Flaise commented 7 years ago

That worked. Thanks for the help. I'm using template strings with Vue, no cross-compilation precisely because of issues like these.