React native packager / bundler无法找到私有模块

时间:2018-05-22 11:41:34

标签: react-native

我试图让原生反应找到项目文件夹之外的模块,并且它适用于大多数模块,但它总是在尝试找到以@ ej开头的模块时跳闸:@ mapbox /反应天然-mapbox-GL

这是我的项目结构

  • 项目

    • 应用
      • RN-cli.config
    • 共享
      • 部件

这是我的rn-cli.config.js

const Path = require('path');
const blacklist = require('metro-bundler/src/blacklist')

module.exports = {
   extraNodeModules: {
    'react-native': Path.resolve(__dirname, 'node_modules/react-native'),
    react: Path.resolve(__dirname, 'node_modules/react'),
    axios: Path.resolve(__dirname, 'node_modules/axios'),
    redux: Path.resolve(__dirname, 'node_modules/redux'),
    moment: Path.resolve(__dirname, 'node_modules/moment'),
    'react-native-navigation': Path.resolve(__dirname, 'node_modules/react-native-navigation'),
    'react-redux': Path.resolve(__dirname, 'node_modules/react-redux'),
    'redux-thunk': Path.resolve(__dirname, 'node_modules/redux-thunk'),
    'react-native-google-sign-in': Path.resolve(__dirname, 'node_modules/react-native-google-sign-in'),
    'react-native-facebook-login': Path.resolve(__dirname, 'node_modules/react-native-facebook-login'),
    'reactotron-react-native': Path.resolve(__dirname, 'node_modules/reactotron-react-native'),
    'react-native-linear-gradient': Path.resolve(__dirname, 'node_modules/react-native-linear-gradient'),
    'lodash': Path.resolve(__dirname, 'node_modules/lodash'),
    'react-native-communications': Path.resolve(__dirname,'node_modules/react-native-communications'),
    'react-native-vector-icons': Path.resolve(__dirname, 'node_modules/react-native-vector-icons'),
    'react-native-fast-image': Path.resolve(__dirname, 'node_modules/react-native-fast-image'),
    'react-native-share': Path.resolve(__dirname, 'node_modules/react-native-share'),
    'react-native-fetch-blob': Path.resolve(__dirname, 'node_modules/react-native-fetch-blob'),
    '@mapbox/react-native-mapbox-gl': Path.resolve(__dirname, 'node_modules/@mapbox/react-native-mapbox-gl')
},
getProjectRoots: () => [__dirname, Path.join(__dirname, '../../shared')],
};

导入除@ mapbox / react-native-mapbox-gl以外的所有内容,这会导致以下错误:

Unable to resolve module `@mapbox/react-native-mapbox-gl` from `/Users/jose/Desktop/townapps/shared/components/mapPopup/index.tsx`: Module `@mapbox/react-native-mapbox-gl` does not exist in the Haste module map or in these directories:
  /Users/jose/Desktop/townapps/shared/node_modules/@mapbox

0 个答案:

没有答案