effrenus / yandex-map-react

70 stars 22 forks source link

Module not found: Error: Cannot resolve module 'yandex-map-react' #16

Closed robotgo closed 8 years ago

robotgo commented 8 years ago

Столкнулся с проблемой, не удается добавить карту, при запуске webpack выдает ошибку:

ERROR in ./src/js/client.js
Module not found: Error: Cannot resolve module 'yandex-map-react' in D:\Projects\Front\Goalzilla_redux\src\js
 @ ./src/js/client.js 13:22-49

Устанавливаю с помощью команды npm install yandex-map-react При этом в ./node_modules/yandex-map-react/ только 2 файла: package.json и README.md Не могу понять, что я делаю не так.

./src/js/client.js

import React from 'react';
import ReactDom from 'react-dom';
import { Map } from 'yandex-map-react';
class ContactMap extends React.Component {
  render () {
      return (
          <Map onAPIAvailable={function () { console.log('API loaded'); }} center={[55.754734, 37.583314]} zoom={10}>
          </Map>
      );
  }
}
const app = document.getElementById('app');
ReactDom.render(
  <ContactMap />,
  app
);

./package.json

{
  "name": "goalzilla",
  "version": "1.0.0",
  "description": "",
  "main": "webpack.config.js",
  "dependencies": {
    "material-ui": "^0.15.0",
    "react": "^15.1.0",
    "react-dom": "^15.1.0",
    "react-redux": "^4.4.5",
    "react-router": "^2.5.2",
    "react-router-redux": "^4.0.5",
    "react-tap-event-plugin": "^1.0.0",
    "redux": "^3.5.2",
    "yandex-map-react": "^1.0.0-beta.8"
  },
  "devDependencies": {
    "expect": "^1.20.2",
    "deep-freeze": "0.0.1",
    "babel-eslint": "^6.1.0",
    "babel-loader": "^6.2.4",
    "babel-plugin-add-module-exports": "^0.2.1",
    "babel-plugin-react-html-attrs": "^2.0.0",
    "babel-plugin-transform-class-properties": "^6.9.1",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-react": "^6.5.0",
    "babel-preset-stage-0": "^6.5.0",
    "babel-register": "^6.9.0",
    "eslint": "^3.0.0",
    "eslint-loader": "^1.4.0",
    "eslint-plugin-react": "^5.2.2",
    "history": "^3.0.0",
    "mocha": "^2.5.3",
    "react-router": "^2.4.1",
    "webpack": "^1.13.1",
    "webpack-dev-server": "^1.14.1"
  },
  "scripts": {
    "dev": "./node_modules/.bin/webpack-dev-server --content-base src --inline --hot",
    "test": "mocha --compilers js:babel-register --recursive",
    "test:watch": "npm test -- --watch"
  },
  "author": "",
  "license": "ISC"
}

./webpack.config.js

var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');

module.exports = {
  context: path.join(__dirname, "src"),
  devtool: debug ? "inline-sourcemap" : null,
  entry: "./js/client.js",
  module: {
    preLoaders: [ //добавили ESlint в preloaders
      {
        test: /\.js$/,
        loaders: ['eslint'],
        include: [
          path.resolve(__dirname, "src"),
        ],
      }
    ],
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel-loader',
        query: {
          presets: ['react', 'es2015', 'stage-0'],
          plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy'],
        }
      }
    ]
  },
  output: {
    path: __dirname + "/src/",
    filename: "client.min.js"
  },
  plugins: debug ? [] : [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
  ],
};
gribnoysup commented 8 years ago

В репозитории отсутствует папка lib с билдом, которая нужная npm. Сделал PR с фиксом #17

effrenus commented 8 years ago

Привет, немного забросил модуль.( В итоге как решил проблему? Фикс от @gribnoysup помог?

robotgo commented 8 years ago

Да, фикс помог, спасибо!