facebookarchive / relay-starter-kit

Barebones starting point for a Relay application.
Other
1.01k stars 245 forks source link

npm start fails with "ERROR in ./js/app.js" #93

Closed ruslantalpa closed 8 years ago

ruslantalpa commented 8 years ago

Everything used to work even a few days ago but i am guessing something changed in the node/nmp packages and now there is this error

(complete output beginning with clone here http://pastebin.com/Gjkbn7UU)

± |master ✓| → npm start

> relay-starter-kit@0.1.0 start /tmp/relay-starter-kit
> babel-node ./server.js

> relay-starter-kit@0.1.0 update-schema /tmp/relay-starter-kit
> babel-node ./scripts/updateSchema.js

GraphQL server is now running on http://localhost:8080
App is now running on http://localhost:3000
Hash: af279ae28561136eb0fa
Version: webpack 1.13.1
Time: 49ms

ERROR in ./js/app.js
Module build failed: Error: Plugin 0 specified in "foreign" provided an invalid property of "_c"
    at Plugin.init (/tmp/relay-starter-kit/node_modules/babel-core/lib/transformation/plugin.js:138:13)
    at Function.normalisePlugin (/tmp/relay-starter-kit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:147:12)
    at /tmp/relay-starter-kit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:181:30
    at Array.map (native)
    at Function.normalisePlugins (/tmp/relay-starter-kit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:153:20)
    at OptionManager.mergeOptions (/tmp/relay-starter-kit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:245:36)
    at /tmp/relay-starter-kit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:254:17
    at /tmp/relay-starter-kit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:342:20
    at Array.map (native)
    at OptionManager.resolvePresets (/tmp/relay-starter-kit/node_modules/babel-core/lib/transformation/file/options/option-manager.js:305:20)
webpack: bundle is now VALID.

i confirmed the error also with another person with a clean system

ruslantalpa commented 8 years ago

something close to this https://github.com/istarkov/babel-plugin-webpack-loaders/issues/113 seems to indicate it might be a babelrc config issue

ruslantalpa commented 8 years ago

duplicate https://github.com/relayjs/relay-starter-kit/issues/66 sorry

ruslantalpa commented 8 years ago

Actually #66 says it's tracked in https://github.com/facebook/relay/issues/832 and that issue seems to be closed/fixed I also remember that this used to work with node 5 just a few days ago, then i deleted node_modules from the project dir, did a install, and this is when it failed.

~$ node -v
v5.10.1
~$ npm -v
3.8.3

it also fails with

~$ node -v
v4.5.0
~$ npm -v
2.15.9
andyfen commented 8 years ago

yeah getting it too, think it worked 2 days ago.

Error: Plugin 0 specified in "foreign" provided an invalid property of "_c"

lfittl commented 8 years ago

FWIW, replacing the inline plugin with https://github.com/BerndWessels/babel-relay-plugin-loader did the trick for me.

diff --git a/.babelrc b/.babelrc
index 6a1d5dc..cc957c8 100644
--- a/.babelrc
+++ b/.babelrc
@@ -1,13 +1,19 @@
 {
-  "passPerPreset": true,
   "presets": [
-    {
-      "plugins": [
-        "./build/babelRelayPlugin"
-      ]
-    },
     "react",
     "es2015",
     "stage-0"
-  ]
+  ],
+  "env": {
+    "development": {
+      "plugins": [
+        "babel-relay-plugin-loader"
+      ]
+    },
+    "production": {
+      "plugins": [
+        "babel-relay-plugin-loader"
+      ]
+    }
+  },
 }
diff --git a/package.json b/package.json
index 02d698c..c906192 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
     "babel-preset-react": "^6.11.1",
     "babel-preset-stage-0": "6.5.0",
     "babel-relay-plugin": "0.9.2",
+    "babel-relay-plugin-loader": "^0.9.0",
     "chokidar": "1.6.0",
     "classnames": "2.2.5",
     "express": "4.14.0",
@@ -31,5 +32,10 @@
   },
   "devDependencies": {
     "babel-cli": "6.11.4"
+  },
+  "metadata": {
+    "graphql": {
+      "schema": "./data/schema.json"
+    }
   }
 }
ruslantalpa commented 8 years ago

The above patch fixes the issue for me too. Thanks @lfittl

wincent commented 8 years ago

Thanks for the discussion everybody.

We're planning to release a new version of Relay this week (0.9.3). I am not sure how many people are affected by this error, and we have a workaround, so my proposal is to close this for now. Once 0.9.3 is out, we should update the relay-starter-kit's dependency on it.

If things are still broken for some people, I'd be open to merging a PR that adds the babel-relay-plugin-loader package, but that would be separate from this issue.

andyfen commented 8 years ago

pull request https://github.com/relayjs/relay-starter-kit/pull/94

fgali commented 7 years ago

Can you help me with this?

ERROR in ./source/App.js Module build failed: Error: Plugin 19 specified in "E:\ReactTest\ho la-mundo\node_modules\babel-preset-es2015\index.js" provided an in valid property of "__esModule" at Plugin.init (E:\ReactTest\hola-mundo\node_modules\babel-core\l ib\transformation\plugin.js:124:13) at Function.normalisePlugin (E:\ReactTest\hola-mundo\node_modules \babel-core\lib\transformation\file\options\option-manager.js:155:12) at E:\ReactTest\hola-mundo\node_modules\babel-core\lib\transforma tion\file\options\option-manager.js:184:30 at Array.map (native) at Function.normalisePlugins (E:\ReactTest\hola-mundo\node_module s\babel-core\lib\transformation\file\options\option-manager.js:161:20 ) at OptionManager.mergeOptions (E:\ReactTest\hola-mundo\node_modul es\babel-core\lib\transformation\file\options\option-manager.js:254:3 6) at OptionManager.mergePresets (E:\ReactTest\hola-mundo\node_modul es\babel-core\lib\transformation\file\options\option-manager.js:308:1 6) at OptionManager.mergeOptions (E:\ReactTest\hola-mundo\node_modules\babel-core\lib\transformation\file\options\option-manager.js:270:12) at OptionManager.init (E:\ReactTest\hola-mundo\node_modules\babel-core\lib\transformation\file\options\option-manager.js:396:10) at File.initOptions (E:\ReactTest\hola-mundo\node_modules\babel-core\lib\transformation\file\index.js:191:75) @ multi main

fgali commented 7 years ago

package.json:

{ "name": "hello-app", "version": "1.0.0", "description": "", "scripts": { "start": "node_modules/.bin/webpack-dev-server --progress" }, "author": "", "license": "ISC", "devDependencies": { "babel-core": "~6.0.", "babel-loader": "~6.0.", "babel-preset-es2015": "~6.0.", "babel-preset-react": "~6.0.", "webpack": "^1.12.14", "webpack-dev-server": "^1.14.1" }, "dependencies": { "react": "^15.0.0", "react-dom": "^15.0.0" } }

fgali commented 7 years ago

webpack.config.js:

module.exports = { entry: [ './source/App.js' ], output: { path: __dirname, filename: 'bundle.js' }, module: { loaders: [{ test: /.jsx?$/, exclude: /node_modules/, loader: 'babel', query: { presets: ['es2015','react'] } }] } };