2017-09-05 49 views
2

我目前正試圖將我們現有的vue.js項目轉換爲nuxt.js.我無法在nuxt.js中添加flowtype支持。當我運行流量服務器時,它說沒有錯誤!但運行npm run dev,它在流語法上拋出錯誤。如何在Nuxt.js中實現FlowType

.flowconfig 

[include] 
pages/**/.* 
components/**/.* 
layouts/**/.* 
apiRoutes/.* 
store/.* 
utils/.* 


[ignore] 
.*/build/.* 
.*/config/.* 
.*/dist/.* 
.*/node_modules/.* 
.*/static/.* 
.*/test/.* 
.*/ssl/.* 
.*/.nuxt/.* 

[libs] 
./flow/ 

[options] 
emoji=true 
module.file_ext=.vue 
module.file_ext=.js 
server.max_workers=3 
log.file=./flow.log 
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe 
unsafe.enable_getters_and_setters=true 
module.system.node.resolve_dirname=node_modules 
module.name_mapper='^.*\.css$' -> 'empty/object' 
module.name_mapper='^.*\.js$' -> 'empty/object' 
module.name_mapper='^@/\(.*\)$' -> '<PROJECT_ROOT>/\1' 

我已經添加了所有neccessary巴貝爾和eslint包。

.babelrc 
{ 
    "presets": [ 
    ["env", { "modules": false }], 
    "stage-2", 
    ["es2015", {"modules": false }], 
    "flow-vue" 
    ], 
    "plugins": [ 
    "transform-runtime", 
    "transform-class-properties", 
    "syntax-flow", 
    "transform-flow-strip-types" 
    ], 
    "comments": false, 
    "env": { 
    "test": { 
     "presets": ["env", "stage-2"], 
     "plugins": [ "istanbul" ] 
    } 
    } 
} 

.eslintrc.js 
module.exports = { 
    root: true, 
    parserOptions: { 
    parser: 'babel-eslint', 
    sourceType: 'module' 
    }, 
    env: { 
    browser: true, 
    node: true, 
    jquery: true 
    }, 
    extends: [ 
    'standard', 
    'plugin:flowtype/recommended' 
    // 'plugin:vue/recommended' 
    ], 
    // required to lint *.vue files 
    plugins: [ 
    'html', 
    'flowtype-errors', 
    'flowtype' 
    ], 
    // add your custom rules here 
    rules: { 
    'flowtype-errors/show-errors': 2, 
    // allow paren-less arrow functions 
    'arrow-parens': 0, 
    'semi': ["error", "always"], 
    // allow async-await 
    'generator-star-spacing': 0 
    }, 
    globals: {} 
} 

在運行NPM運行開發,它不解析流動型語法

flowtype_error

回答

0

我建議以下的instructions on the flow website成立巴貝爾。特別是有一個預置,所以你不需要配置單獨的規則。那麼你實際上需要運行Babel(再次,說明在網站上)。一旦你運行了Babel,你應該能夠運行它在Node中輸出的代碼。

+1

仍然沒有幫助。我在某種程度上將我的問題縮小到了nuxt處理webpack配置的方式。如果我運行'npm run build',它完美的工作。我相信dev開發的方式不起作用。 – nemoblob