2016-06-09 24 views
1

Willkommen,Modul kann nicht gefunden werden

Ich bin neu in React und Node.js vor allem. Ich wollte etwas über React lernen und endete mit Node.js. Das Problem ist, dass ich einen Web-Dev-Server nicht richtig einstellen kann. Tut mir leid, wenn diese Frage trivial erscheint, obwohl ich seit Stunden keine Lösung gefunden habe.

Hier ist sie: 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://localhost:8080/app/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\""); }()); 


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

Ich erhalte auch solchen warrning, wenn ich versuche webpack-dev-Server herzustellen: CMD Error

Ach ich schon npm installed das Modul erforderlich (zumindest sollte es so sein).

Ich habe keine Ahnung, was ich tun muss, um es funktioniert zu machen :(

+0

Was ist die Verzeichnisstruktur Ihrer Anwendung Stellen Sie sicher, das en try Punkt ist in './src/index.js' – zeronone

+1

Der Fehler im Bild sagt, dass lodash nicht gefunden wird. Versuchen Sie 'npm install --save lodash' – zeronone

+0

Vielen Dank für Ihre Antworten, aber sie haben nicht geholfen. 1. Ich kann nicht npm installieren --save lodash, es führt zu einem Fehler. Trotzdem habe ich lodash als dependency und devDependency in der package.json Datei hinzugefügt. Wenn ich npn installiere, läuft es, aber webpack-dev-server kann es nicht noch finden. 2. Meine Dateistruktur ist sicher in Ordnung :( – 0blivion6

Antwort

1

Es scheint, dass lodash sollte über npm install enthalten sein, aber webpack-dev-Server kann es nicht finden:

npm install

0

Es ist ein Cache-Fehler oder so ähnlich, dass eine schnelle Lösung sein kann.?

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