当我从命令行运行Reactjs项目时出现错误:npm运行它

时间:2017-05-11 22:38:52

标签: javascript node.js reactjs

在reactjs@1.0.0上失败,脚本'webpack-dev-server'。 确保安装了最新版本的node.js和npm。 如果这样做,这很可能是reactjs包的问题, 不是与npm本身。告诉作者你的系统失败了:  webpack-dev-server您可以通过以下方式获取有关如何为此项目打开问题的信息:npm bugs reactjs或者如果不可用,您可以通过以下方式获取其信息:npm owner ls reactjs上面可能还有其他日志记录输出。

npm ERR! node v6.10.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! reactjs@1.0.0 it: `webpack-dev-server`
npm ERR! Exit status 1

我的Webpack.config.js

var path = require("webpack");


module.exports = {
  entry: "./script.js",
  output: {
    path: path.resolve(__dirname, + "/build"),
    filename: "index.js"
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: "babel-loader",
        exclude: /node_modules/,
        query: {
          presets: ["es2015", "react"]
        }
      }
    ]
  }

}

package.json

{
  "name": "reactjs",
  "version": "1.0.0",
  "description": "Starter kit for React course by Jack",
  "main": "index.js",
  "scripts": {
    "it": "webpack-dev-server", "<----- something wrong here"
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "VladBelo",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.24.0",
    "babel-loader": "^6.4.1",
    "babel-preset-es2015": "^6.24.0",
    "babel-preset-react": "^6.23.0",
    "eslint": "^3.19.0",
    "eslint-plugin-react": "^7.0.0",
    "webpack": "^2.4.2"
  },
  "dependencies": {
    "react": "^15.4.2",
    "react-dom": "^15.4.2"
  }

}

2 个答案:

答案 0 :(得分:0)

看起来没有安装webpack-dev-erver。请全局安装并重试。

答案 1 :(得分:0)

在命令行中,通过

安装Webpack Dev Server
npm install --save webpack-dev-server