javascript - 新人网上找了个项目,build时报错
怪我咯
怪我咯 2017-04-11 09:40:05
[JavaScript讨论组]

项目是material-ui的入门例子,安装完模块后执行build和start都会报错,是我本地的环境问题吗?系统是win10,node是6.2.0,npm是3.8.9。
项目地址:material-ui-webpack
module安装情况:

D:\myProgram\material-ui-webpack>npm install
material-ui-example-webpack@0.15.0 D:\myProgram\material-ui-webpack
+-- babel-core@6.18.2
| +-- babel-code-frame@6.16.0
| | +-- chalk@1.1.3
| | | +-- ansi-styles@2.2.1
| | | +-- escape-string-regexp@1.0.5
| | | +-- has-ansi@2.0.0
| | | `-- supports-color@2.0.0
| | +-- esutils@2.0.2
| | `-- js-tokens@2.0.0
| +-- babel-generator@6.19.0
| | +-- detect-indent@4.0.0
| | | `-- repeating@2.0.1
| | |   `-- is-finite@1.0.2
| | |     `-- number-is-nan@1.0.1
| | `-- jsesc@1.3.0
| +-- babel-helpers@6.16.0
| +-- babel-messages@6.8.0
| +-- babel-register@6.18.0
| | +-- core-js@2.4.1
| | +-- home-or-tmp@2.0.0
| | | +-- os-homedir@1.0.2
| | | `-- os-tmpdir@1.0.2
| | `-- source-map-support@0.4.6
| +-- babel-runtime@6.18.0
| | +-- core-js@2.4.1
| | `-- regenerator-runtime@0.9.6
| +-- babel-template@6.16.0
| +-- babel-traverse@6.19.0
| | +-- globals@9.14.0
| | `-- invariant@2.2.2
| +-- babel-types@6.19.0
| | `-- to-fast-properties@1.0.2
| +-- babylon@6.14.1
| +-- convert-source-map@1.3.0
| +-- debug@2.3.3
| | `-- ms@0.7.2
| +-- json5@0.5.0
| +-- lodash@4.17.2
| +-- minimatch@3.0.3
| | `-- brace-expansion@1.1.6
| |   +-- balanced-match@0.4.2
| |   `-- concat-map@0.0.1
| +-- path-is-absolute@1.0.1
| +-- private@0.1.6
| +-- slash@1.0.0
| `-- source-map@0.5.6
+-- babel-loader@6.2.8
| +-- find-cache-dir@0.1.1
| | +-- commondir@1.0.1
| | `-- pkg-dir@1.0.0
| |   `-- find-up@1.1.2
| |     +-- path-exists@2.1.0
| |     `-- pinkie-promise@2.0.1
| |       `-- pinkie@2.0.4
| +-- loader-utils@0.2.16
| | +-- big.js@3.1.3
| | `-- emojis-list@2.1.0
| +-- mkdirp@0.5.1
| | `-- minimist@0.0.8
| `-- object-assign@4.1.0
+-- babel-preset-es2015@6.18.0
| +-- babel-plugin-check-es2015-constants@6.8.0
| +-- babel-plugin-transform-es2015-arrow-functions@6.8.0
| +-- babel-plugin-transform-es2015-block-scoped-functions@6.8.0
| +-- babel-plugin-transform-es2015-block-scoping@6.18.0
| +-- babel-plugin-transform-es2015-classes@6.18.0
| | +-- babel-helper-define-map@6.18.0
| | +-- babel-helper-function-name@6.18.0
| | +-- babel-helper-optimise-call-expression@6.18.0
| | `-- babel-helper-replace-supers@6.18.0
| +-- babel-plugin-transform-es2015-computed-properties@6.8.0
| +-- babel-plugin-transform-es2015-destructuring@6.19.0
| +-- babel-plugin-transform-es2015-duplicate-keys@6.8.0
| +-- babel-plugin-transform-es2015-for-of@6.18.0
| +-- babel-plugin-transform-es2015-function-name@6.9.0
| +-- babel-plugin-transform-es2015-literals@6.8.0
| +-- babel-plugin-transform-es2015-modules-amd@6.18.0
| +-- babel-plugin-transform-es2015-modules-commonjs@6.18.0
| | `-- babel-plugin-transform-strict-mode@6.18.0
| +-- babel-plugin-transform-es2015-modules-systemjs@6.19.0
| | `-- babel-helper-hoist-variables@6.18.0
| +-- babel-plugin-transform-es2015-modules-umd@6.18.0
| +-- babel-plugin-transform-es2015-object-super@6.8.0
| +-- babel-plugin-transform-es2015-parameters@6.18.0
| | +-- babel-helper-call-delegate@6.18.0
| | `-- babel-helper-get-function-arity@6.18.0
| +-- babel-plugin-transform-es2015-shorthand-properties@6.18.0
| +-- babel-plugin-transform-es2015-spread@6.8.0
| +-- babel-plugin-transform-es2015-sticky-regex@6.8.0
| | `-- babel-helper-regex@6.18.0
| +-- babel-plugin-transform-es2015-template-literals@6.8.0
| +-- babel-plugin-transform-es2015-typeof-symbol@6.18.0
| +-- babel-plugin-transform-es2015-unicode-regex@6.11.0
| | `-- regexpu-core@2.0.0
| |   +-- regenerate@1.3.2
| |   +-- regjsgen@0.2.0
| |   `-- regjsparser@0.1.5
| |     `-- jsesc@0.5.0
| `-- babel-plugin-transform-regenerator@6.16.1
+-- babel-preset-react@6.16.0
| +-- babel-plugin-syntax-flow@6.18.0
| +-- babel-plugin-syntax-jsx@6.18.0
| +-- babel-plugin-transform-flow-strip-types@6.18.0
| +-- babel-plugin-transform-react-display-name@6.8.0
| +-- babel-plugin-transform-react-jsx@6.8.0
| | `-- babel-helper-builder-react-jsx@6.18.0
| +-- babel-plugin-transform-react-jsx-self@6.11.0
| `-- babel-plugin-transform-react-jsx-source@6.9.0
+-- html-webpack-plugin@2.24.1
| +-- bluebird@3.4.6
| +-- html-minifier@3.2.3
| | +-- camel-case@3.0.0
| | | +-- no-case@2.3.0
| | | | `-- lower-case@1.1.3
| | | `-- upper-case@1.1.3
| | +-- clean-css@3.4.21
| | | +-- commander@2.8.1
| | | `-- source-map@0.4.4
| | +-- commander@2.9.0
| | | `-- graceful-readlink@1.0.1
| | +-- he@1.1.0
| | +-- ncname@1.0.0
| | | `-- xml-char-classes@1.0.0
| | +-- param-case@2.1.0
| | `-- relateurl@0.2.7
| +-- pretty-error@2.0.2
| | +-- renderkid@2.0.0
| | | +-- css-select@1.2.0
| | | | +-- boolbase@1.0.0
| | | | +-- css-what@2.1.0
| | | | +-- domutils@1.5.1
| | | | | `-- dom-serializer@0.1.0
| | | | |   +-- domelementtype@1.1.3
| | | | |   `-- entities@1.1.1
| | | | `-- nth-check@1.0.1
| | | +-- dom-converter@0.1.4
| | | | `-- utila@0.3.3
| | | +-- htmlparser2@3.3.0
| | | | +-- domelementtype@1.3.0
| | | | +-- domhandler@2.1.0
| | | | `-- domutils@1.1.6
| | | `-- utila@0.3.3
| | `-- utila@0.4.0
| `-- toposort@1.0.0
+-- material-ui@0.15.4
| +-- inline-style-prefixer@2.0.5
| | +-- bowser@1.5.0
| | `-- hyphenate-style-name@1.0.2
| +-- keycode@2.1.7
| +-- react-addons-create-fragment@15.4.1
| +-- react-addons-transition-group@15.4.1
| +-- react-event-listener@0.2.1
| +-- recompose@0.20.2
| | +-- change-emitter@0.1.2
| | +-- hoist-non-react-statics@1.2.0
| | `-- symbol-observable@0.2.4
| +-- simple-assign@0.1.0
| `-- warning@3.0.0
+-- react@15.4.1
| +-- fbjs@0.8.6
| | +-- core-js@1.2.7
| | +-- isomorphic-fetch@2.2.1
| | | +-- node-fetch@1.6.3
| | | | +-- encoding@0.1.12
| | | | | `-- iconv-lite@0.4.15
| | | | `-- is-stream@1.1.0
| | | `-- whatwg-fetch@2.0.1
| | +-- promise@7.1.1
| | | `-- asap@2.0.5
| | `-- ua-parser-js@0.7.12
| `-- loose-envify@1.3.0
+-- react-dom@15.4.1
+-- react-hot-loader@1.3.0
| +-- react-hot-api@0.4.7
| `-- source-map@0.4.4
|   `-- amdefine@1.0.1
+-- react-tap-event-plugin@1.0.0
| `-- fbjs@0.2.1
|   `-- whatwg-fetch@0.9.0
+-- transfer-webpack-plugin@0.1.4
| +-- node-dir@0.1.16
| `-- vow@0.4.13
+-- webpack@1.13.3
| +-- acorn@3.3.0
| +-- async@1.5.2
| +-- clone@1.0.2
| +-- enhanced-resolve@0.9.1
| | +-- graceful-fs@4.1.11
| | `-- memory-fs@0.2.0
| +-- interpret@0.6.6
| +-- memory-fs@0.3.0
| | +-- errno@0.1.4
| | | `-- prr@0.0.0
| | `-- readable-stream@2.2.2
| |   +-- buffer-shims@1.0.0
| |   +-- core-util-is@1.0.2
| |   +-- isarray@1.0.0
| |   +-- process-nextick-args@1.0.7
| |   `-- util-deprecate@1.0.2
| +-- node-libs-browser@0.6.0
| | +-- assert@1.4.1
| | +-- browserify-zlib@0.1.4
| | | `-- pako@0.2.9
| | +-- buffer@4.9.1
| | | +-- base64-js@1.2.0
| | | +-- ieee754@1.1.8
| | | `-- isarray@1.0.0
| | +-- console-browserify@1.1.0
| | | `-- date-now@0.1.4
| | +-- constants-browserify@0.0.1
| | +-- crypto-browserify@3.2.8
| | | +-- pbkdf2-compat@2.0.1
| | | +-- ripemd160@0.2.0
| | | `-- sha.js@2.2.6
| | +-- domain-browser@1.1.7
| | +-- events@1.1.1
| | +-- http-browserify@1.7.0
| | | `-- Base64@0.2.1
| | +-- https-browserify@0.0.0
| | +-- os-browserify@0.1.2
| | +-- path-browserify@0.0.0
| | +-- process@0.11.9
| | +-- punycode@1.4.1
| | +-- querystring-es3@0.2.1
| | +-- readable-stream@1.1.14
| | | `-- isarray@0.0.1
| | +-- stream-browserify@1.0.0
| | | `-- readable-stream@1.0.34
| | +-- string_decoder@0.10.31
| | +-- timers-browserify@1.4.2
| | +-- tty-browserify@0.0.0
| | +-- url@0.10.3
| | | +-- punycode@1.3.2
| | | `-- querystring@0.2.0
| | +-- util@0.10.3
| | | `-- inherits@2.0.1
| | `-- vm-browserify@0.0.4
| |   `-- indexof@0.0.1
| +-- optimist@0.6.1
| | `-- wordwrap@0.0.2
| +-- supports-color@3.1.2
| | `-- has-flag@1.0.0
| +-- tapable@0.1.10
| +-- uglify-js@2.7.4
| | +-- async@0.2.10
| | +-- uglify-to-browserify@1.0.2
| | `-- yargs@3.10.0
| |   +-- camelcase@1.2.1
| |   +-- cliui@2.1.0
| |   | +-- center-align@0.1.3
| |   | | +-- align-text@0.1.4
| |   | | | +-- longest@1.0.1
| |   | | | `-- repeat-string@1.6.1
| |   | | `-- lazy-cache@1.0.4
| |   | `-- right-align@0.1.3
| |   +-- decamelize@1.2.0
| |   `-- window-size@0.1.0
| +-- watchpack@0.2.9
| | +-- async@0.9.2
| | `-- chokidar@1.6.1
| |   +-- anymatch@1.3.0
| |   | `-- arrify@1.0.1
| |   +-- async-each@1.0.1
| |   +-- glob-parent@2.0.0
| |   +-- is-binary-path@1.0.1
| |   | `-- binary-extensions@1.7.0
| |   +-- is-glob@2.0.1
| |   `-- readdirp@2.1.0
| |     +-- readable-stream@2.2.2
| |     | `-- isarray@1.0.0
| |     `-- set-immediate-shim@1.0.1
| `-- webpack-core@0.6.8
|   +-- source-list-map@0.1.6
|   `-- source-map@0.4.4
`-- webpack-dev-server@1.16.2
  +-- compression@1.6.2
  | +-- accepts@1.3.3
  | | `-- negotiator@0.6.1
  | +-- bytes@2.3.0
  | +-- compressible@2.0.9
  | | `-- mime-db@1.25.0
  | +-- debug@2.2.0
  | | `-- ms@0.7.1
  | +-- on-headers@1.0.1
  | `-- vary@1.1.0
  +-- connect-history-api-fallback@1.3.0
  +-- express@4.14.0
  | +-- array-flatten@1.1.1
  | +-- content-disposition@0.5.1
  | +-- content-type@1.0.2
  | +-- cookie@0.3.1
  | +-- cookie-signature@1.0.6
  | +-- debug@2.2.0
  | | `-- ms@0.7.1
  | +-- depd@1.1.0
  | +-- encodeurl@1.0.1
  | +-- escape-html@1.0.3
  | +-- etag@1.7.0
  | +-- finalhandler@0.5.0
  | | +-- debug@2.2.0
  | | | `-- ms@0.7.1
  | | +-- statuses@1.3.1
  | | `-- unpipe@1.0.0
  | +-- fresh@0.3.0
  | +-- merge-descriptors@1.0.1
  | +-- methods@1.1.2
  | +-- on-finished@2.3.0
  | | `-- ee-first@1.1.1
  | +-- parseurl@1.3.1
  | +-- path-to-regexp@0.1.7
  | +-- proxy-addr@1.1.2
  | | +-- forwarded@0.1.0
  | | `-- ipaddr.js@1.1.1
  | +-- qs@6.2.0
  | +-- range-parser@1.2.0
  | +-- send@0.14.1
  | | +-- debug@2.2.0
  | | +-- destroy@1.0.4
  | | `-- ms@0.7.1
  | +-- serve-static@1.11.1
  | +-- type-is@1.6.14
  | | `-- media-typer@0.3.0
  | `-- utils-merge@1.0.0
  +-- http-proxy-middleware@0.17.2
  | +-- http-proxy@1.15.2
  | | +-- eventemitter3@1.2.0
  | | `-- requires-port@1.0.0
  | +-- is-glob@3.1.0
  | | `-- is-extglob@2.1.0
  | `-- micromatch@2.3.11
  |   +-- arr-diff@2.0.0
  |   | `-- arr-flatten@1.0.1
  |   +-- array-unique@0.2.1
  |   +-- braces@1.8.5
  |   | +-- expand-range@1.8.2
  |   | | `-- fill-range@2.2.3
  |   | |   +-- is-number@2.1.0
  |   | |   +-- isobject@2.1.0
  |   | |   | `-- isarray@1.0.0
  |   | |   `-- randomatic@1.1.6
  |   | +-- preserve@0.2.0
  |   | `-- repeat-element@1.1.2
  |   +-- expand-brackets@0.1.5
  |   | `-- is-posix-bracket@0.1.1
  |   +-- extglob@0.3.2
  |   +-- filename-regex@2.0.0
  |   +-- is-extglob@1.0.0
  |   +-- kind-of@3.0.4
  |   | `-- is-buffer@1.1.4
  |   +-- normalize-path@2.0.1
  |   +-- object.omit@2.0.1
  |   | +-- for-own@0.1.4
  |   | | `-- for-in@0.1.6
  |   | `-- is-extendable@0.1.1
  |   +-- parse-glob@3.0.4
  |   | +-- glob-base@0.3.0
  |   | `-- is-dotfile@1.0.2
  |   `-- regex-cache@0.4.3
  |     +-- is-equal-shallow@0.1.3
  |     `-- is-primitive@2.0.0
  +-- open@0.0.5
  +-- serve-index@1.8.0
  | +-- batch@0.5.3
  | +-- debug@2.2.0
  | | `-- ms@0.7.1
  | +-- http-errors@1.5.1
  | | `-- setprototypeof@1.0.2
  | `-- mime-types@2.1.13
  +-- sockjs@0.3.18
  | +-- faye-websocket@0.10.0
  | | `-- websocket-driver@0.6.5
  | |   `-- websocket-extensions@0.1.1
  | `-- uuid@2.0.3
  +-- sockjs-client@1.1.1
  | +-- eventsource@0.1.6
  | | `-- original@1.0.0
  | |   `-- url-parse@1.0.5
  | +-- faye-websocket@0.11.0
  | +-- inherits@2.0.3
  | +-- json3@3.3.2
  | `-- url-parse@1.1.7
  |   `-- querystringify@0.0.4
  +-- stream-cache@0.0.2
  +-- strip-ansi@3.0.1
  | `-- ansi-regex@2.0.0
  +-- supports-color@3.1.2
  `-- webpack-dev-middleware@1.8.4
    `-- mime@1.3.4

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.15

build报错:
start报错:
package.json如下:

{
  "name": "material-ui-example-webpack",
  "version": "0.15.0",
  "description": "Sample project that uses Material-UI",
  "repository": {
    "type": "git",
    "url": "https://github.com/callemall/material-ui.git"
  },
  "scripts": {
    "start": "webpack-dev-server --config webpack-dev-server.config.js --progress --inline --colors",
    "build": "webpack --config webpack-production.config.js --progress --colors"
  },
  "private": true,
  "devDependencies": {
    "babel-core": "^6.3.26",
    "babel-loader": "^6.2.4",
    "babel-preset-es2015": "^6.3.13",
    "babel-preset-react": "^6.3.13",
    "html-webpack-plugin": "^2.7.2",
    "react-hot-loader": "^1.3.0",
    "transfer-webpack-plugin": "^0.1.4",
    "webpack": "^1.12.9",
    "webpack-dev-server": "^1.14.0"
  },
  "dependencies": {
    "material-ui": "^0.15.0",
    "react": "^15.0.1",
    "react-dom": "^15.0.1",
    "react-tap-event-plugin": "^1.0.0"
  }
}

webpack.config.js如下:

const webpack = require('webpack');
const path = require('path');
const buildPath = path.resolve(__dirname, 'build');
const nodeModulesPath = path.resolve(__dirname, 'node_modules');
const TransferWebpackPlugin = require('transfer-webpack-plugin');

const config = {
  entry: [path.join(__dirname, '/src/app/app.js')],
  // Render source-map file for final build
  devtool: 'source-map',
  // output config
  output: {
    path: buildPath, // Path of output file
    filename: 'app.js', // Name of output file
  },
  plugins: [
    // Define production build to allow React to strip out unnecessary checks
    new webpack.DefinePlugin({
      'process.env':{
        'NODE_ENV': JSON.stringify('production')
      }
    }),
    // Minify the bundle
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        // suppresses warnings, usually from module minification
        warnings: false,
      },
    }),
    // Allows error warnings but does not stop compiling.
    new webpack.NoErrorsPlugin(),
    // Transfer Files
    new TransferWebpackPlugin([
      {from: 'www'},
    ], path.resolve(__dirname, 'src')),
  ],
  module: {
    loaders: [
      {
        test: /\.js$/, // All .js files
        loaders: ['babel-loader'], // react-hot is like browser sync and babel loads jsx and es6-7
        exclude: [nodeModulesPath],
      },
    ],
  },
};

module.exports = config;
怪我咯
怪我咯

走同样的路,发现不同的人生

全部回复(3)
PHP中文网

你需要先执行npm install将作者用到的模块下载下来。

PHP中文网

see https://github.com/npm/npm/is...

npm install --no-optional

能贴下npm install的执行过程吗

PHPz

我遇到过 react版本的问题
你换成15.3.2试一下

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号