reactjs - 如何编译 React-Relay
问题描述
我正在尝试遵循官方的 Relay 文档。
安装 React-Relay 后:
npm install --save relay-runtime react-relay
npm install --save-dev relay-compiler graphql babel-plugin-relay
...并配置 package.json:
{
...
"scripts": {
...
"start": "npm run relay && react-scripts start",
"build": "npm run relay && react-scripts build",
"relay": "npm run relay-compiler --schema schema.graphql --src ./src/ --watchman false $@"
...
},
...
}
当我跑的时候:
npm start
我收到以下错误:
> test@0.1.0 start D:\xampp\htdocs\my-react\test
> npm run relay && react-scripts start
> test@0.1.0 relay D:\xampp\htdocs\my-react\test
> npm run relay-compiler --schema schema.graphql --src ./src/ --watchman false $@
npm ERR! missing script: relay-compiler
如何正确运行中继编译器?
解决方案
显然,我必须在 package.json 的最后一行删除“npm run”:
{
...
"scripts": {
...
"start": "npm run relay && react-scripts start",
"build": "npm run relay && react-scripts build",
"relay": "relay-compiler --schema schema.graphql --src ./src/ --watchman false $@"
...
},
...
}
推荐阅读
- python - 如何将熊猫数据框导出到 Teradata 表中
- c# - .Net Core 3.1 Worker Service with Entity Framework Core SqlServer 在 SaveChanges() 上出错
- php - PHP Laravel:如何访问数组上的受保护值
- java - 扩展现有的 hybris cronjob 以通过电子邮件发送自定义结果
- tomcat - Tomcat 8.5 和 java 11。无法获取数据源。名称未绑定在此上下文中
- javascript - 切换按钮无法正常工作
- mysql - 如何构建雪花查询以获得这些结果
- ruby-on-rails - Rails 6 + UJS:在没有 jQuery 的情况下对模糊进行 ajax 调用
- visual-studio - 从 Jenkins 运行 Visual Studio 项目
- google-sheets - 我可以使用公式在 Google 表格中将多个单元格合并为一个单元格吗?(提供示例表)