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

[0.46] Packager fails: Unknown plugin "transform-runtime" #14530

Closed
sjmueller opened this issue Jun 15, 2017 · 41 comments
Closed

[0.46] Packager fails: Unknown plugin "transform-runtime" #14530

sjmueller opened this issue Jun 15, 2017 · 41 comments
Assignees
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@sjmueller
Copy link
Contributor

Create a fresh app with: react-native init rn46 --version "0.46.0-rc.2", then CMD+R in Xcode which attempts to fire up the packager, but immediately bombs with:

ReferenceError: Unknown plugin "transform-runtime" specified in "/rn46/node_modules/regenerator-transform/package.json" at 0, attempted to resolve relative to "/rn46/node_modules/regenerator-transform" (While processing preset: "/rn46/node_modules/babel-preset-react-native/index.js")
    at /rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:17
    at Array.map (native)
    at Function.normalisePlugins (/rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
    at OptionManager.mergeOptions (/rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
    at OptionManager.init (/rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at compile (/rn46/node_modules/babel-register/lib/node.js:103:45)
    at loader (/rn46/node_modules/babel-register/lib/node.js:144:14)
    at Object.require.extensions.(anonymous function) [as .js] (/rn46/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)

Since it's a reference error, I add the dependency npm i babel-plugin-transform-runtime --save-dev and rerun, which now bombs with:

Error: Couldn't find preset "env" relative to directory "/rn46/node_modules/regenerator-transform" (While processing preset: "/rn46/node_modules/babel-preset-react-native/index.js")
    at /rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
    at Array.map (native)
    at OptionManager.resolvePresets (/rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at compile (/rn46/node_modules/babel-register/lib/node.js:103:45)
    at loader (/rn46/node_modules/babel-register/lib/node.js:144:14)
    at Object.require.extensions.(anonymous function) [as .js] (/rn46/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:488:32)

Okay, let's now try npm i --save-dev babel-preset-env, which bombs with:

Error: Options {"loose":true} passed to /rn46/node_modules/babel-preset-env/lib/index.js which does not accept options. (While processing preset: "/rn46/node_modules/babel-preset-env/lib/index.js") (While processing preset: "/rn46/node_modules/babel-preset-env/lib/index.js") (While processing preset: "/rn46/node_modules/babel-preset-react-native/index.js")
    at /rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:314:17
    at Array.map (native)
    at OptionManager.resolvePresets (/rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/rn46/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at compile (/rn46/node_modules/babel-register/lib/node.js:103:45)
    at loader (/rn46/node_modules/babel-register/lib/node.js:144:14)
    at Object.require.extensions.(anonymous function) [as .js] (/rn46/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:488:32)

Something has definitely gone wrong down this rabbit hole. I noticed that @davidaurelio just upgraded babel-preset-react-native with commit bc22a4d, not sure if it's related but the update is already showing up in the initialized package.json:

	"devDependencies": {
		"babel-jest": "20.0.3",
		"babel-preset-react-native": "2.0.0",
		"jest": "20.0.4",
		"react-test-renderer": "16.0.0-alpha.12"
	}
@SudoPlz
Copy link
Contributor

SudoPlz commented Jun 20, 2017

I've got the exact same problem after upgrading to 0.46.0-rc.2, @sjmueller have you managed to sort that out?

@SudoPlz
Copy link
Contributor

SudoPlz commented Jun 20, 2017

Ok rm -rf .babelrc on the project root solved that problem for me. No idea why.

@sjmueller
Copy link
Contributor Author

I haven't been able to sort it out yet. Tried a bunch of different things, but reverted and now stuck on 0.44 until this can be fixed.

@SudoPlz
Copy link
Contributor

SudoPlz commented Jun 20, 2017

Why don't you just delete the .babelrc file @sjmueller ?

@sjmueller
Copy link
Contributor Author

@SudoPlz because I'm using transform-decorators-legacy in my project, and I have decorators all over the place.

However just to check, I did try deleting my .babelrc just to see if it get passed the problem; it does, but unfortunately I just get slammed with Unable to resolve module 'AccessibilityInfo' that everyone is dealing with on #14209. Yes I tried:

rm -rf node_modules
rm -rf $TMPDIR/react-*
watchman watch-del-all
npm i
npm start -- --reset-cache

So gracious for what react-native and the core team, but honestly the amount of instability over the past few releases is pretty staggering -- 0.44.2+, 0.45+, and 0.46 rc all have their own set of problems. We really need the bug fixes in FlatList and NativeAnimated in the past two months, but can't get at them no matter how hard we try...

@grabbou
Copy link
Contributor

grabbou commented Jul 5, 2017

Just to put more context here:

Looks that the problem is Packager trying to transpile regenerator-transform that has been already transpiled before publishing to npm. It still defines transform-runtime in its package.json, however it's under dev dependencies. That could also apply to other dependencies.

Another explanation of similar issue from another repository: redux-orm/redux-orm#24 (comment)

@nprz
Copy link

nprz commented Jul 5, 2017

Currently getting this error as well...

ReferenceError: Unknown plugin "transform-runtime" specified in "/../node_modules/regenerator-transform/package.json"

on version 0.46.0 of react native

@joriswa
Copy link

joriswa commented Jul 5, 2017

Also getting this error in 0.46.0

Update: rm -rf .babelrc and re-running react-native run-ios fixed the issue for me

@nprz
Copy link

nprz commented Jul 5, 2017

@joriswa I just tried this and it works. Any insight as to why that fixed the issue or if that fix will cause any other issues down the road?

@joriswa
Copy link

joriswa commented Jul 5, 2017

@nprz I got no idea whatsoever.

@cmdshepard
Copy link

cmdshepard commented Jul 5, 2017

Also got this error after upgrading from 0.45 to 0.46

I resolved it by deleting .babelrc and then adding babel-plugin-transform-runtime & regenerator-transform to dev dependencies.

Then running ./node_modules/react-native/scripts/packager.sh --reset-cache

@grabbou grabbou changed the title [0.46.0-rc.2] Packager fails: Unknown plugin "transform-runtime" [0.46] Packager fails: Unknown plugin "transform-runtime" Jul 6, 2017
@raunaqss
Copy link

raunaqss commented Jul 6, 2017

Dong this rm -rf .babelrc resolved the issue for me as well. However, I'm concerned whether this will create more problems ahead..

@SudoPlz Would really appreciate if you could enlighten me as to why this solves the problem?

@nprz
The .babelrc file just included the preset react-native, but removing it after facing the above issue doesn't seem to affect the app's behavior (with the same es6/7 code), I guess explicitly mentioning the preset isn't necessary. Or is this assumption wrong?

@JimmyDaddy
Copy link

I deleted .babelrc, then I encountered this problem #14209.

@zamotany
Copy link

zamotany commented Jul 6, 2017

As a quick workaround, you can use haul which works just fine.

@chilijung
Copy link

chilijung commented Jul 6, 2017

delete .babelrc also works for me. But I am also using babel transform-decorators-legacy plugin (like @sjmueller mentioned) , do anyone know how could I use decorators without .babelrc settings? thanks.

@jeanlauliac jeanlauliac self-assigned this Jul 6, 2017
@otoinsa
Copy link

otoinsa commented Jul 6, 2017

The same issue here, wanted to start a new project :(
Both create-react-native-app and react-native init don't function properly...

@0xdavinchee
Copy link

rm -rf .babelrc works, but when I try to run npm install --save redux react-redux in the project directory it causes this error:

screenshot 2017-07-06 11 16 31

I'm assuming this is related to the problem w/ upgrading from 0.45 -> 0.46?

@jeanlauliac
Copy link

I found a solution. This is due to what I think is a kinda-bug in Babel, but I have a workaround anyway. Sending a PR soon.

@cmdshepard
Copy link

@thechee514 try resetting the packager cache
./node_modules/react-native/scripts/packager.sh --reset-cache

@0xdavinchee
Copy link

0xdavinchee commented Jul 6, 2017

@cmdshepard it returns this error:
no such file or directory: ./node_modules/react-native/scripts/packager.sh

Could this be because I have yarnpkg installed? So instead of entering: npm install --save redux react-redux I should enter yarn add redux?

@cmdshepard
Copy link

@thechee514 what version of react-native are you using?

@0xdavinchee
Copy link

@cmdshepard 0.46

@cmdshepard
Copy link

@thechee514 try /Users/thechee514/Documents/workspace/test/node_modules/react-native/scripts/packager.sh --reset-cache

@dioxide
Copy link

dioxide commented Jul 6, 2017

downgrade babel-preset-react-native 2.1.0 to 2.0.0 is working fine in my case.

@0xdavinchee
Copy link

@cmdshepard I'm still getting the same error, here is the output after attempting to install redux:
screenshot 2017-07-06 13 41 34

@cmdshepard
Copy link

@thechee514 You're using react-native 0.45.1 - On this version, the packager is located in a different directory. Try running ./node_modules/react-native/packager/react-native-xcode.sh from your project directory.

@0xdavinchee
Copy link

0xdavinchee commented Jul 6, 2017

@cmdshepard, I'm getting a slightly different error now: ./node_modules/react-native/packager/react-native-xcode.sh must be invoked by Xcode. I was running the code you posted earlier on 0.46. I just downgraded to 0.45.1 cause I kinda gave up on 0.46 for the meantime. But doesn't yarn add redux do the same thing?

@cmdshepard
Copy link

@thechee514 yes. yarn add redux will do the same thing although if you initialized your project using yarn, you should stick to using yarn

@0xdavinchee
Copy link

Okay, I initialized the project with react-native init project, but I think it just uses yarn. Thanks for the help though @cmdshepard!

@jp928
Copy link

jp928 commented Jul 6, 2017

I don't know why Facebook releases RN with bug which is so obvious. User reported this issue in rc and the bug still exists in the stable release. User even couldn't run a react-native init
and make it run straightforward. Similar packager issue was found in 0.45. So disappointing.

@jeanlauliac
Copy link

jeanlauliac commented Jul 7, 2017

So, the original problem "Unknown plugin "transform-runtime"" should now be fixed for v0.46 if you do a clean set-up, or if you upgrade the metro-bundler package to 0.7.8 in your repo/lockfile. I'll wait for confirmation this is fixed for you folks as well before closing.

Creating a project from scratch with v0.46 worked for me, and the simulator loads the app correctly. For the other problems that may still happen, please open new issues :)

@cpojer
Copy link
Contributor

cpojer commented Jul 7, 2017

@jp928 Facebook doesn't manage open source releases for react-native, and we are probably not as actively involved as we should be. There are probably ways we can get better at this, but if this is a huge problem for you, it would be awesome if you could step up and help us avoid this class of problems in the future by helping us straighten out the release cycle.

@grabbou
Copy link
Contributor

grabbou commented Jul 7, 2017

@jp928 I am really sorry for the inconvenience. The "RC" bug report somewhat got lost in my inbox full of notifications. During manual testing that I usually do (as well as testing on the CI) the bug wasn't revealed. Sometimes not every single issue can be reproduced, but I think we did our best to fix it as soon as possible post the release.

@fungilation
Copy link

fungilation commented Jul 7, 2017

So is a minor release fix coming? I'm working around with a manual react-native start, as run-ios result in the babel related packager errors. Other workarounds haven't worked for me on getting run-ios to work.

A side question is this: does this affect production releases of my own RN app, which wouldn't be tied to a running instance of the packager?

Repasting from the other issue, my package.json:

{
  "name": "<name>",
  "version": "0.0.1",
  "private": true,
  "eslintConfig": {
    "parserOptions": {
      "ecmaVersion": 6,
      "sourceType": "module",
      "ecmaFeatures": {
        "jsx": true,
        "experimentalObjectRestSpread": true
      }
    },
    "env": {
      "browser": true,
      "node": true
    },
    "plugins": [
      "react",
      "react-native"
    ],
    "rules": {
      "comma-dangle": [
        2,
        "always-multiline"
      ],
      "semi": [
        2,
        "never"
      ],
      "react-native/no-unused-styles": 2,
      "react-native/split-platform-components": 2
    }
  },
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  "dependencies": {
    "babel-plugin-idx": "^1.1.0",
    "bugsnag-react-native": "^2.2.3",
    "he": "^1.1.0",
    "lodash": "^4.17.2",
    "moment-timezone": "^0.5.10",
    "node-summary": "file:../node-summary/",
    "react": "16.0.0-alpha.12",
    "react-native": "0.46.0",
    "react-native-blur": "^3.1",
    "react-native-code-push": "3.0.1-beta",
    "react-native-firebase-analytics": "^3.0.0",
    "react-native-fit-image": "^1.4.8",
    "react-native-highlight-words": "^1.0.0",
    "react-native-keep-awake": "^2.0.4",
    "react-native-linear-gradient": "^2.0.0",
    "react-native-modalbox": "^1.3.8",
    "react-native-notification": "^2.0.0",
    "react-native-orientation": "file:../react-native-orientation-RN0.40/",
    "react-native-parallax-scroll-view": "^0.19.0",
    "react-native-safari-view": "^2.0.0",
    "react-native-status-bar-size": "^0.3.2",
    "react-native-swiper": "^1.5.4",
    "react-native-tooltip": "^5.0.0",
    "react-native-tts": "^1.3.0",
    "react-native-vector-icons": "^4.1.1",
    "react-native-webview-bridge": "file:../react-native-webview-bridge-RN0.40/",
    "react-redux": "^5.0.1",
    "realm": "^1.3.1",
    "redux": "^3.6.0",
    "redux-thunk": "^2.1.0"
  },
  "devDependencies": {
    "redux-logger": "^3.0.6"
  }
}

.babelrc:

{
  "presets": ["react-native"],
  "plugins": ["idx"]
}

@grabbou
Copy link
Contributor

grabbou commented Jul 7, 2017 via email

@fungilation
Copy link

Can you clarify on "you will get latest patch version every time you do a fresh install"? Does it include running a react-native-git-upgrade?

@jeanlauliac
Copy link

Does it include running a react-native-git-upgrade?

I believe not. The action necessary depends on what package manager you use. For yarn, you have to upgrade the version of metro-bundler used in the lockfile. I believe yarn upgrade can be used for that. For npm 5, there should be a similar command to upgrade the locked dependencies, but I'm not familiar. For npm 4, deleting node_modules and running npm install again should do the deal, or upgrading the shrinkwrap file if any.

@fungilation
Copy link

fungilation commented Jul 7, 2017

I confirm fixed with yarn upgrade, and inside yarn.lock file went from version "0.7.6" to version "0.7.8", under the line metro-bundler@^0.7.4:. Thanks for the clarification!

A side issue I noticed now on React Packager's terminal below. Does this warrant a new issue?

Loading dependency graph...jest-haste-map: @providesModule naming collision:
  Duplicate module name: base64-js
  Paths: /Users/<user>/Documents/code/<project>/node_modules/react-native/node_modules/base64-js/package.json collides with /Users/<user>/Documents/code/<project>/node_modules/react-native/node_modules/simple-plist/node_modules/base64-js/package.json

This warning is caused by a @providesModule declaration with the same name across two different files.

@jeanlauliac
Copy link

jeanlauliac commented Jul 7, 2017

A side issue I noticed now on React Packager's terminal below. Does this warrant a new issue?

I believe it's the issue reported in facebook/metro#18. We have a fix that's been landed, not sure when will it spread to react-native yet.

@fungilation
Copy link

That's fine, shouldn't be a blocker as it's just a console warning.

@grabbou
Copy link
Contributor

grabbou commented Jul 11, 2017

Going to close it as it looks like the issue has been resolved :)

@grabbou grabbou closed this as completed Jul 11, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Jul 11, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.