reactjs - 无法在 Laravel 项目中安装 Flow for React
问题描述
我正在开发一个 Laravel 应用程序。对于前端,我使用的是 React JS。现在我正在尝试将 Flow 集成到我的项目中。我点击了这个链接https://flow.org/en/docs/install/。但不工作。
我在根文件夹中运行此命令
npm install --save-dev babel-cli babel-preset-flow
然后在项目根文件夹中创建 .babelrc 文件,内容如下
{
"presets": ["flow"]
}
然后我运行这个命令
npm install --save-dev flow-bin
这是我的 package.json
{
"private": true,
"scripts": {
"flow": "flow",
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"@babel/preset-react": "^7.0.0",
"axios": "^0.18.0",
"babel-cli": "^6.26.0",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.23.0",
"bootstrap": "^4.2.1",
"cross-env": "^5.1",
"flow-bin": "^0.89.0",
"jquery": "^3.2",
"laravel-mix": "^4.0.7",
"lodash": "^4.17.5",
"popper.js": "^1.12",
"react": "^16.2.0",
"react-dom": "^16.7.0",
"react-scripts": "^2.1.2",
"resolve-url-loader": "^2.3.1",
"sass": "^1.15.2",
"sass-loader": "^7.1.0"
},
"dependencies": {
"@coreui/coreui": "github:coreui/coreui",
"@coreui/coreui-plugin-chartjs-custom-tooltips": "github:coreui/coreui-plugin-chartjs-custom-tooltips",
"@coreui/react": "^2.1.2",
"classnames": "^2.2.6",
"core-js": "^2.6.1",
"enzyme": "^3.8.0",
"flag-icon-css": "^3.2.1",
"font-awesome": "^4.7.0",
"node-sass": "^4.11.0",
"prop-types": "^15.6.2",
"react-app-polyfill": "^0.1.3",
"react-loadable": "^5.5.0",
"react-redux": "^6.0.0",
"react-router": "^4.3.1",
"react-router-config": "^4.4.0-beta.6",
"react-router-dom": "^4.3.1",
"react-test-renderer": "^16.7.0",
"reactstrap": "^6.5.0",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0",
"simple-line-icons": "^2.4.1"
}
}
然后我运行这个
npm run flow init
那么这个
npm run flow
运行上述命令时出现此错误。
> @ flow /Users/wai/Desktop/easy-eat
> flow
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ vendor/symfony/translation/Tests/fixtures/empty.json:1:1
Unexpected end of input
1│
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ vendor/symfony/translation/Tests/fixtures/malformed.json:2:11
Unexpected string
1│ {
2│ "foo" "bar"
3│ }
Found 2 errors
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ flow: `flow`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ flow script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/wai/.npm/_logs/2018-12-28T21_01_36_563Z-debug.log
缺少什么,我该如何解决?
解决方案
我也遇到了这个。默认情况下,Flow 将检查项目中的所有目录。.flowconfig
您可以通过在项目的根目录中创建文件来修复此错误。(运行yarn run flow init
也会为你创建这个文件)
确保vendor
通过此配置忽略文件夹。我的配置如下所示:
[ignore]
.*/vendor/.*
[include]
[libs]
[lints]
[options]
[strict]
推荐阅读
- php - 在正文中包含重定向
- c++ - 析构函数 C++ 使内存泄漏
- twilio - 在 twilio 中指定请求中的声音文件
- ajax - 分页 AJAX LARAVEL [帮助]
- c++ - 如何在不设置 ulimit -n 的情况下解决 Socket 程序打开文件过多错误
- python - 使用 GDCMSeriesFileNames 或路径列表读取的 DICOM 图像
- javascript - 在 Servicenow 表单上提交时的静态日期格式
- qt - 我的 QRubberBand 坐标与我的图像不对应
- sql - Oracle 批处理
- php - 如何查询在 Laravel 中通过请求接收到的字符串?