找不到模块:错误:无法解析' file'或者'目录' ./src @ multi main

时间:2016-10-15 21:41:07

标签: javascript reactjs module babel

我一直在关注反应todo-app教程并收到此错误。

  

多主机中的错误
  找不到模块:错误:无法解析' file'或者'目录' ./src
  @多主。

WEBPACK.CONFIG.JS

var webpack = require('webpack');
var path = require('path');

module.exports = {
  devtool: 'inline-source-map',
  entry: [
  'webpack-dev-server/client?http://127.0.0.1:8080/',
  'webpack/hot/only-dev-server',
  './src'
  ],
  output: {
    path: path.resolve(__dirname, 'public'),
    filename: 'bundle.js'
  },
  resolve: {
    modulesDirectories: ['node_modules', 'src'],
    extensions: ['', '.js']
  },
  module: {
    loaders: [
    {
      test: /\.jsx$/,
      exclude: /node_modules/,
      loaders: [ 'react-hot-loader','babel-loader']
    }
    ]
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
  ]
};

的package.json:

{
  "name": "taskmaven2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node server"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Marcode777/taskmaven2.git"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/Marcode777/taskmaven2/issues"
  },
  "homepage": "https://github.com/Marcode777/taskmaven2#readme",
  "dependencies": {
    "express": "^4.13.4",
    "lodash": "^4.2.1",
    "react": "^15.3.2",
    "react-dom": "^15.3.2"
  },
  "devDependencies": {
    "babel-core": "^6.17.0",
    "babel-loader": "^6.2.5",
    "babel-preset-es2015": "^6.16.0",
    "babel-preset-react": "^6.16.0",
    "react-hot-loader": "^1.3.0",
    "webpack": "^1.13.2",
    "webpack-dev-server": "^1.16.2"
  },
  "engines": {
    "node": "5.5.0"
  }
}

APP.JS

import React from "react";

export default class App extends React.Component {
  render(){
    return(
      <div>
        <h1>TASKMAVEN2</h1>
      </div>
      );
  }
}

INDEX.JSX:

import React from 'react';
import {render} from 'react-dom';
import App from './components/app';

console.log(App);
render(<App/>, document.getElementById("app"));

0 个答案:

没有答案