gpt4 book ai didi

reactjs - 'foreign' 中指定的插件 0 提供了无效的属性 '_c'

转载 作者:行者123 更新时间:2023-12-03 14:21:19 63 4
gpt4 key购买 nike

使用以下配置出现上述错误,我应该如何使其工作?

.babelrc:

{
"passPerPreset": true,
"presets": [
{"plugins": ["./build/babelRelayPlugin"]},
"react",
"es2015",
"stage-0"
]
}

package.json:

{
"name": "1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-polyfill": "^6.13.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-0": "^6.5.0",
"babel-relay-plugin": "^0.9.2",
"express": "^4.14.0",
"express-graphql": "^0.5.3",
"graphql": "^0.6.2",
"graphql-relay": "^0.4.2",
"react": "^15.3.1",
"react-dom": "^15.3.1",
"react-relay": "^0.9.2",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.15.0"
},
"devDependencies": {
"babel-cli": "^6.14.0"
}
}

服务器.js:

//
//
//
const compiler = webpack({
entry: path.resolve(__dirname, 'js', 'app.js'),
module: {
loaders: [
{
test: /\.js$/,
include: [ path.resolve(__dirname, "js") ],
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-0'],
},
}
],
},
output: {filename: '/app.js', path: '/', publicPath: '/js/'}
});
const appServer = new WebpackDevServer(compiler, {
contentBase: '/public/',
proxy: {'/graphql': 'http://localhost:8000'},
publicPath: '/js/',
stats: {colors: true}
});
//
//
//

终端错误:babel-node server.js

./js/app.js 中出现错误
模块构建失败:错误:“foreign”中指定的插件 0 提供了无效的“_c”属性

浏览器错误:本地主机:3000

在控制台窗口中:

未捕获的不变违规:RelayQL:运行时意外调用。 Babel 转换未设置,或者无法识别此调用站点。确保它被逐字用作 Relay.QL

最佳答案

我使用以下设置取得了成功。我在我的 webpack 模块中而不是在 .babelrc

中使用带有 babel 加载器的插件

在网络包中:

query: {
presets: [
"es2015", "react", "stage-0", {
"plugins": [
"./schema-build/babelRelayPlugin"
]
}
]
}

在 .babelrc 中:

{
"passPerPreset": true,
"presets": [
"react",
"es2015",
"stage-0"
]
}

关于reactjs - 'foreign' 中指定的插件 0 提供了无效的属性 '_c',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39158809/

63 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com