繁体   English   中英

Webpack-dev-server找不到模块

[英]Webpack-dev-server Cannot find module

欢迎,

我是React和Node.js的新手。 我想学习一些关于React的东西并最终与Node.js斗争。 问题是我无法正确设置web-dev服务器。 对不起,如果这个问题似乎很简单,虽然我几个小时都找不到解决方案。

这是: webpack.config.js

module.exports = {
    entry: './src/index.js',
    output: {
        path: __dirname,
        filename: 'app/js/main.js'
    },
    module: {
        loaders: [{
                test: /\.jsx?$/,
                loader: 'babel',
                exclude: /node_modules/
            }]
    }
}

的package.json

{
  "name": "Github_profile_viewer",
  "version": "0.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "BSD", 
  "devDependencies": {
    "babel-core": "5.8.*",
    "babel-loader": "5.3.*",
    "webpack": "1.12.*",
    "webpack-dev-server": "1.10.*"
  },
  "dependencies": {
    "react": "^0.14,7",
    "react-dom": "^0.14.7"
  }
}

HTTP://本地主机:8080 /应用/ JS / main.js

/******/ (function(modules) { // webpackBootstrap
/******/    // The module cache
/******/    var installedModules = {};

/******/    // The require function
/******/    function __webpack_require__(moduleId) {

/******/        // Check if module is in cache
/******/        if(installedModules[moduleId])
/******/            return installedModules[moduleId].exports;

/******/        // Create a new module (and put it into the cache)
/******/        var module = installedModules[moduleId] = {
/******/            exports: {},
/******/            id: moduleId,
/******/            loaded: false
/******/        };

/******/        // Execute the module function
/******/        modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/        // Flag the module as loaded
/******/        module.loaded = true;

/******/        // Return the exports of the module
/******/        return module.exports;
/******/    }


/******/    // expose the modules object (__webpack_modules__)
/******/    __webpack_require__.m = modules;

/******/    // expose the module cache
/******/    __webpack_require__.c = installedModules;

/******/    // __webpack_public_path__
/******/    __webpack_require__.p = "";

/******/    // Load entry module and return exports
/******/    return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

    (function webpackMissingModule() { throw new Error("Cannot find module \"./src/index.js\""); }());


/***/ }
/******/ ]);

当我尝试建立webpack-dev-server: CMD Error时,我也收到了这样的警告

唉我已经npm installednpm installed所需的模块(至少应该是这样)。

我不知道我要做些什么让它起作用:(

似乎应该通过npm install包含lodash,但是webpack-dev-server找不到它:

npm安装

这是一个缓存错误或类似的东西。 快速解决方案可能是:

rm -rf node_modules
rm -rf ~/.npm
npm install -g npm
npm install

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM