Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

babel-preset-env 1.3.0 throws "Target version must be a number" when forge start is run #186

Closed
biomade opened this issue Apr 1, 2017 · 17 comments
Labels
blocked/upstream Issues blocked by upstream bugs bug

Comments

@biomade
Copy link

biomade commented Apr 1, 2017

  • [ x] I have read the contribution documentation for this project.
  • [x ] I agree to follow the code of conduct that this project follows, as appropriate.
  • [x ] I have searched the issue tracker for an issue that matches the one I want to file, without success.

Please describe your issue:
I just created a new app per the instructions on the read me.
I set the template to be react and it all installed
I then did an npm install to get the remaining dependencies and from my command window ran: npm start.
And this is the error I received below.
FYI I am running on Windows10 and node is v6.10.0

Here is the output WITHOUT the debug variable

> myforgewithreact@0.0.1 start C:\Users\laurie\Documents\GitHub\UITests\myforgewithreact
> electron-forge start

√ Checking your system
√ Locating Application
√ Preparing native dependencies
√ Launching Application

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

What command line arguments are you passing? NONE

What does your config.forge data in package.json look like? (did not change it)

  "config": {
    "forge": {
      "make_targets": {
        "win32": [
          "squirrel"
        ],
        "darwin": [
          "zip"
        ],
        "linux": [
          "deb",
          "rpm"
        ]
      },
      "electronPackagerConfig": {},
      "electronWinstallerConfig": {
        "name": "myforgewithreact"
      },
      "electronInstallerDebian": {},
      "electronInstallerRedhat": {},
      "github_repository": {
        "owner": "",
        "name": ""
      },
      "windowsStoreConfig": {
        "packageName": "",
        "name": "myforgewithreact"
      }
    }
  }
@malept
Copy link
Member

malept commented Apr 1, 2017

This broke with babel/babel-preset-env#229, I'm trying to figure out how to fix it.

@malept malept added bug blocked/upstream Issues blocked by upstream bugs labels Apr 1, 2017
@biomade
Copy link
Author

biomade commented Apr 1, 2017

I saw the other issues with different versions of node, I blew away the node-modules folder and reinstalled the packages to no avail. I also tried the install without the react framework, same problem.
Thanks for the attention.

@malept
Copy link
Member

malept commented Apr 1, 2017

Until I figure out how to fix this, in your Electron project, fix the babel-preset-env version in package.json to: "^1.2.2, < 1.3.0"

@biomade
Copy link
Author

biomade commented Apr 1, 2017

let me try it and I will get back to you in a moment

@malept malept changed the title Application fails at start - App threw an error during load babel-preset-env 1.3.0 throws "Target version must be a number" when forge start is run Apr 1, 2017
@biomade
Copy link
Author

biomade commented Apr 1, 2017

;-(( NOPE!
I changed the package.json, ran npm install then npm start. Same error! So what's next?
App threw an error during load Error: Target version must be a number, '1.6.0' was given for 'electron' (While processing preset: "C:\\Users\\laurie\\Documents\\GitHub\\UITests\\myforgewithreact\\node_modules\\babel-preset-env\\lib\\index.js") at C:\Users\laurie\Documents\GitHub\UITests\myforgewithreact\node_modules\babel-preset-env\lib\index.js:64:13 at Array.filter (native) at isPluginRequired (C:\Users\laurie\Documents\GitHub\UITests\myforgewithreact\node_modules\babel-preset-env\lib\index.js:54:54) at filterItem (C:\Users\laurie\Documents\GitHub\UITests\myforgewithreact\node_modules\babel-preset-env\lib\index.js:166:20) at Array.filter (native) at buildPreset (C:\Users\laurie\Documents\GitHub\UITests\myforgewithreact\node_modules\babel-preset-env\lib\index.js:215:56) at C:\Users\laurie\Documents\GitHub\UITests\myforgewithreact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:317:46 at Array.map (native) at OptionManager.resolvePresets (C:\Users\laurie\Documents\GitHub\UITests\myforgewithreact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20) at OptionManager.mergePresets (C:\Users\laurie\Documents\GitHub\UITests\myforgewithreact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)

@malept
Copy link
Member

malept commented Apr 1, 2017

Make sure babel-preset-env has 1.2.2 installed and not 1.3.0. This is my repro instructions:

electron-forge init testbabel
cd testbabel
$EDITOR package.json # change version
npm install
npm start

@biomade
Copy link
Author

biomade commented Apr 1, 2017

alright, I will admit I am now confused.
I just looked at the babel-preset-env. package json and it has "raw": "babel-preset-env@^1.3.2"
I changed the babel-preset-env version in the main project package. json. Should I now blow away the babel-preset-env folder in the modules folder or the entire modules folder

@biomade
Copy link
Author

biomade commented Apr 1, 2017

well that did not work (blowing away the modules folder) now I get another weird message. I am going to restart the process.. (yes I am new at this)

@biomade
Copy link
Author

biomade commented Apr 1, 2017

OK we have lift off!
I created a new application and before I ran npm install, I went and changed the version in the package. Then after the install, I went into the modules folder and checked that the version was correct; and it was.
I was then able to get my app to start!!!

i will let you decide to close the ticket, attach it to the other error or leave it open. Thanks @malept for all your help, now I can start to play with react!!

@khawarizmus
Copy link

khawarizmus commented Apr 1, 2017

I had the same issue few hours ago.

Notice also that changing "electron": "1.6.2" to "electron": 1.6 in the .compilerc file solved the issue for me.

@malept
Copy link
Member

malept commented Apr 1, 2017

Yes, babel-preset-env no longer allows string versions for Electron, I hope they fix that.

@malept
Copy link
Member

malept commented Apr 3, 2017

New projects in Forge no longer have this problem as of 2.9.0. It uses a Number for the Electron version instead of a String.

@malept malept closed this as completed Apr 3, 2017
@philcleveland
Copy link

philcleveland commented Apr 4, 2017

I am unsure how to fix this problem with a project created in an older version of forge? I blew away node_modules and updated forge to 2.9.0 and still get

Failed to compile /dev_bin/Elec_grpc_test/src/index.html: Target version must be a number,
          '1.6.2' was given for 'electron' (While processing preset: "/dev_bin/Elec_grpc_test/node_modules/babel-preset-env/lib/index.js")
Error: Target version must be a number,
          '1.6.2' was given for 'electron' (While processing preset: "/dev_bin/Elec_grpc_test/node_modules/babel-preset-env/lib/index.js")
    at /dev_bin/Elec_grpc_test/node_modules/babel-preset-env/lib/index.js:64:13
    at Array.filter (native)
    at isPluginRequired (/dev_bin/Elec_grpc_test/node_modules/babel-preset-env/lib/index.js:54:54)
    at filterItem (/dev_bin/Elec_grpc_test/node_modules/babel-preset-env/lib/index.js:166:20)
    at Array.filter (native)
    at buildPreset (/dev_bin/Elec_grpc_test/node_modules/babel-preset-env/lib/index.js:215:56)
    at /dev_bin/Elec_grpc_test/node_modules/babel-core/lib/transformation/file/options/option-manager.js:317:46
    at Array.map (native)
    at OptionManager.resolvePresets (/dev_bin/Elec_grpc_test/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/dev_bin/Elec_grpc_test/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)

Here are dependencies

"dependencies": {
    "@types/electron": "^1.4.33",
    "@types/electron-devtools-installer": "^2.0.2",
    "@types/react": "^0.14.57",
    "@types/react-dom": "^0.14.23",
    "@types/react-router": "^4.0.3",
    "electron-compile": "^6.1.3",
    "electron-devtools-installer": "^2.1.0",
    "grpc": "git+https://github.com/philcleveland/grpc.git",
    "history": "^4.6.1",
    "react": "^15.4.2",
    "react-dom": "^15.4.2",
    "react-hot-loader": "^3.0.0-beta.6",
    "react-router": "^4.0.0",
    "tslib": "^1.6.0"
  },
  "devDependencies": {
    "@types/rx": "^4.1.1",
    "babel-plugin-transform-async-to-generator": "^6.22.0",
    "babel-preset-env": "^1.2.1",
    "babel-preset-react": "^6.23.0",
    "electron-prebuilt-compile": "1.6.2",
    "protobufjs": "^6.6.5",
    "rxjs": "^5.2.0",
    "tslint": "^4.5.1",
    "typescript": "^2.1.6"
  }

@malept
Copy link
Member

malept commented Apr 4, 2017

Use @gimyboya's solution for existing projects. The change needs to be in .compilerc.

@philcleveland
Copy link

OK. I am assuming that since the fix is in .compilerc that I will need to recompile? Is there anyway to force forge to do so without blowing away node_modules? Thanks

@malept
Copy link
Member

malept commented Apr 4, 2017

No, you won't need to recompile. Does it matter?

@philcleveland
Copy link

Nope recompile does not matter. I was just curious. @gimyboya 's solution did work for me. It will only work with major/minor e.g. 1.6 and not 1.6.2. The latter causes a parse error in the json. Not exactly sure why, but it is not affecting me. Thanks for the help. I am up and running again. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked/upstream Issues blocked by upstream bugs bug
Projects
None yet
Development

No branches or pull requests

4 participants