找不到所需的流程模块 [英] Flow required module not found

查看:95
本文介绍了找不到所需的流程模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Webpack 2,流程0.46.0

Using Webpack 2, Flow 0.46.0

我有一个正在开发的大型应用程序,因此正在使用Webpack解析模块来创建别名导入名称,例如从"../../../../constants/ServiceURI"到"constants/ServiceURI"

I have a pretty large app I am developing, so am using Webpack resolve modules to create alias import names e.g. '../../../../constants/ServiceURI' to 'constants/ServiceURI'

一切正常,直到添加流量为止.必须有一种使用mapper或resolve_dirname的方法来解决此问题,但是我不知道如何解决.不管我做什么,都会中断流程.

Everything works fine until I add flow. There must be a way to use mapper or resolve_dirname to fix this, but I cannot figure out how. No matter what I do it breaks flow.

我真的很想使用流,但这对我来说是一个障碍.

I really want to use flow, but this is a blocker for me.

项目结构:

./flowconfig
./webpack.config.js
./src
    /js
        /constants
        /actions
        /...
    /css

Webpack配置如下:

Webpack config looks like:

resolve: {
        modules: [
            path.resolve('./src/js'),
            path.resolve('./src/js/constants'),
            'node_modules'
        ],
        extensions: ['.js', '.jsx']

流配置如下:

[ignore]
.*/node_modules/*

[include]
<PROJECT_ROOT>/src/js/

[libs]

[options]
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
esproposal.export_star_as=enable
esproposal.decorators=ignore

# Tried this
module.name_mapper='^constants$' -> '<PROJECT_ROOT>/src/js/constants'

# Tried using this too
module.system.node.resolve_dirname=./src/js

module.system=haste
munge_underscores=true

[version]
0.46.0

流错误:

rc/js/actions/ActionActivity.js:6
  6: import { ACTIVITY_API } from 'constants/ServiceURI'
                                  ^^^^^^^^^^^^^^^^^^^^^^ 
constants/ServiceURI. Required module not found

推荐答案

您在module.name_mapper中使用的正则表达式与constants/ServiceURI不匹配.它仅与constants完全匹配.您还需要匹配constants之后的所有内容,以便能够解析constants目录中的所有模块.

The regular expression you're using in the module.name_mapper does not match constants/ServiceURI. It only matches exactly constants. You additionally need to match anything that comes after constants to be able to resolve all modules inside the constants directory.

module.name_mapper='^constants/\(.*\)$' -> '<PROJECT_ROOT>/src/js/constants/\1'

\(\)创建捕获组的地方(需要斜杠),您可以将其称为\1.有关更多信息,请参见 module.name_mapper .

Where \( and \) create a capturing group (the slashes are required), which you can refer to as \1. For more information see module.name_mapper.

这篇关于找不到所需的流程模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆