找不到模块:无法解析react-raphael-map

时间:2017-06-08 01:55:26

标签: node.js reactjs create-react-app

我试图在creat-react-app上使用react-raphael-map,但是问题是

./src/App.js Module not found: Can't resolve 'react-raphael-map' in 'C:\workspace\maptestproject\src'

我跑了create-react-app maptestproject;

然后npm install --save raphael

然后npm install --save react-raphael-map

App.js被修改为:

import React, { Component } from 'react';
import Map from 'react-raphael-map';
import logo from './logo.svg';
import './App.css';

class App extends Component {
  render() {
    var china= {
        aomen: {
            name: "澳门",
            path: "M413.032...",
            yy: 10
        },
        hk:{
            name: "香港",
            path: "M417.745...",
            xx: 20
        },
        taiwan: {
            name: "台湾",
            path: "M505.438..."
        },
        guangdong: {
            name: "广东",
            path: "M391.37...",
            yy: -10
        },
        guangxi: {
            name: "广西",
            path: "M305.646..."
        }
    }

    return (<Map data={china} width={480} height={560} />)
  }
}

export default App;

在他的例子中,反应 - raphael-map在他的结构中有babel和webpack文件,顺便说一下create-react-app不行。有必要吗?

有人如何解决?

1 个答案:

答案 0 :(得分:-1)

问题发生在node_modules\react-raphael-map,在package.json档案中,行"main": "index.js"行指向index.js,但没有。 index.js位于node_modules\react-raphael-map\lib内。