无法在Laravel项目中安装Flow for React

问题描述 投票:1回答:1

我正在开发一个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

缺少什么,我该如何解决?

reactjs laravel flowtype laravel-mix
1个回答
0
投票

我也碰到了这个。默认情况下,Flow将检查项目中的所有目录。您可以通过在项目的根目录中创建.flowconfig文件来修复此错误。 (运行yarn run flow init也会为你创建这个文件)

确保通过此配置忽略vendor文件夹。我的配置如下所示:

[ignore]
.*/vendor/.*

[include]

[libs]

[lints]

[options]

[strict]
© www.soinside.com 2019 - 2024. All rights reserved.