ES6-webpack-babel样板中的错误

时间:2016-10-08 08:55:02

标签: ecmascript-6 webpack

我使用的是我在互联网上找到的ES6-react-webpack样板文件。它工作正常。现在,我想剥掉它以摆脱reactjs元素。我收到以下错误:

xtd8865@darkstar:~/data/projects/reactjs/es6-template/template$ npm start

> react-es6-webpack-boilerplate@4.0.0 start /home/xtd8865/data/projects/reactjs/es6-template/template
> node server.js

Listening at localhost:5000
Hash: 8ee3d46227d899f9d9c3
Version: webpack 1.13.2
Time: 3914ms
    Asset    Size  Chunks       Chunk Names
bundle.js  666 kB       0       main
chunk    {0} bundle.js (main) 224 kB [rendered]
    [0] multi main 52 bytes {0} [built] [1 error]
    [1] (webpack)-dev-server/client?http://localhost:5000 3.97 kB {0} [built]
    [2] (webpack)/~/node-libs-browser/~/url/url.js 22.3 kB {0} [built]
    [3] (webpack)/~/node-libs-browser/~/url/~/punycode/punycode.js 14.6 kB {0} [built]
    [4] (webpack)/buildin/module.js 251 bytes {0} [built]
    [5] (webpack)/~/node-libs-browser/~/url/~/querystring/index.js 127 bytes {0} [built]
    [6] (webpack)/~/node-libs-browser/~/url/~/querystring/decode.js 2.4 kB {0} [built]
    [7] (webpack)/~/node-libs-browser/~/url/~/querystring/encode.js 2.09 kB {0} [built]
    [8] (webpack)-dev-server/~/strip-ansi/index.js 161 bytes {0} [built]
    [9] (webpack)-dev-server/~/strip-ansi/~/ansi-regex/index.js 135 bytes {0} [built]
   [10] (webpack)-dev-server/client/socket.js 856 bytes {0} [built]
   [11] (webpack)-dev-server/~/sockjs-client/lib/entry.js 244 bytes {0} [built]
   [12] (webpack)-dev-server/~/sockjs-client/lib/transport-list.js 613 bytes {0} [built]
   [13] (webpack)-dev-server/~/sockjs-client/lib/transport/websocket.js 2.71 kB {0} [built]
   [14] (webpack)/~/node-libs-browser/~/process/browser.js 5.3 kB {0} [built]
   [15] (webpack)-dev-server/~/sockjs-client/lib/utils/event.js 2 kB {0} [built]
   [16] (webpack)-dev-server/~/sockjs-client/lib/utils/random.js 746 bytes {0} [built]
   [17] (webpack)-dev-server/~/sockjs-client/lib/utils/browser-crypto.js 438 bytes {0} [built]
   [18] (webpack)-dev-server/~/sockjs-client/lib/utils/url.js 975 bytes {0} [built]
   [19] (webpack)-dev-server/~/sockjs-client/~/url-parse/index.js 9.91 kB {0} [built]
   [20] (webpack)-dev-server/~/sockjs-client/~/url-parse/~/requires-port/index.js 753 bytes {0} [built]
   [21] (webpack)-dev-server/~/sockjs-client/~/url-parse/lolcation.js 1.58 kB {0} [built]
   [22] (webpack)-dev-server/~/sockjs-client/~/url-parse/~/querystringify/index.js 1.3 kB {0} [built]
   [23] (webpack)-dev-server/~/sockjs-client/~/debug/browser.js 3.76 kB {0} [built]
   [24] (webpack)-dev-server/~/sockjs-client/~/debug/debug.js 4.1 kB {0} [built]
   [25] (webpack)-dev-server/~/sockjs-client/~/debug/~/ms/index.js 2.33 kB {0} [built]
   [26] (webpack)-dev-server/~/sockjs-client/~/inherits/inherits_browser.js 672 bytes {0} [built]
   [27] (webpack)-dev-server/~/sockjs-client/lib/event/emitter.js 1.27 kB {0} [built]
   [28] (webpack)-dev-server/~/sockjs-client/lib/event/eventtarget.js 1.85 kB {0} [built]
   [29] (webpack)-dev-server/~/sockjs-client/lib/transport/browser/websocket.js 172 bytes {0} [built]
   [30] (webpack)-dev-server/~/sockjs-client/lib/transport/xhr-streaming.js 1.25 kB {0} [built]
   [31] (webpack)-dev-server/~/sockjs-client/lib/transport/lib/ajax-based.js 1.31 kB {0} [built]
   [32] (webpack)-dev-server/~/sockjs-client/lib/transport/lib/sender-receiver.js 1.15 kB {0} [built]
   [33] (webpack)-dev-server/~/sockjs-client/lib/transport/lib/buffered-sender.js 2.3 kB {0} [built]
   [34] (webpack)-dev-server/~/sockjs-client/lib/transport/lib/polling.js 1.32 kB {0} [built]
   [35] (webpack)-dev-server/~/sockjs-client/lib/transport/receiver/xhr.js 1.58 kB {0} [built]
   [36] (webpack)-dev-server/~/sockjs-client/lib/transport/sender/xhr-cors.js 343 bytes {0} [built]
   [37] (webpack)-dev-server/~/sockjs-client/lib/transport/browser/abstract-xhr.js 4.8 kB {0} [built]
   [38] (webpack)-dev-server/~/sockjs-client/lib/transport/sender/xhr-local.js 352 bytes {0} [built]
   [39] (webpack)-dev-server/~/sockjs-client/lib/utils/browser.js 560 bytes {0} [built]
   [40] (webpack)-dev-server/~/sockjs-client/lib/transport/xdr-streaming.js 984 bytes {0} [built]
   [41] (webpack)-dev-server/~/sockjs-client/lib/transport/sender/xdr.js 2.46 kB {0} [built]
   [42] (webpack)-dev-server/~/sockjs-client/lib/transport/eventsource.js 766 bytes {0} [built]
   [43] (webpack)-dev-server/~/sockjs-client/lib/transport/receiver/eventsource.js 1.58 kB {0} [built]
   [44] (webpack)-dev-server/~/sockjs-client/lib/transport/browser/eventsource.js 37 bytes {0} [built]
   [45] (webpack)-dev-server/~/sockjs-client/lib/transport/lib/iframe-wrap.js 981 bytes {0} [built]
   [46] (webpack)-dev-server/~/sockjs-client/lib/transport/iframe.js 3.83 kB {0} [built]
   [47] (webpack)-dev-server/~/sockjs-client/~/json3/lib/json3.js 43.3 kB {0} [built]
   [48] (webpack)/buildin/amd-options.js 43 bytes {0} [built]
   [49] (webpack)-dev-server/~/sockjs-client/lib/version.js 26 bytes {0} [built]
   [50] (webpack)-dev-server/~/sockjs-client/lib/utils/iframe.js 5.06 kB {0} [built]
   [51] (webpack)-dev-server/~/sockjs-client/lib/utils/object.js 532 bytes {0} [built]
   [52] (webpack)-dev-server/~/sockjs-client/lib/transport/htmlfile.js 710 bytes {0} [built]
   [53] (webpack)-dev-server/~/sockjs-client/lib/transport/receiver/htmlfile.js 2.2 kB {0} [built]
   [54] (webpack)-dev-server/~/sockjs-client/lib/transport/xhr-polling.js 894 bytes {0} [built]
   [55] (webpack)-dev-server/~/sockjs-client/lib/transport/xdr-polling.js 712 bytes {0} [built]
   [56] (webpack)-dev-server/~/sockjs-client/lib/transport/jsonp-polling.js 1.02 kB {0} [built]
   [57] (webpack)-dev-server/~/sockjs-client/lib/transport/receiver/jsonp.js 5.57 kB {0} [built]
   [58] (webpack)-dev-server/~/sockjs-client/lib/transport/sender/jsonp.js 2.46 kB {0} [built]
   [59] (webpack)-dev-server/~/sockjs-client/lib/main.js 11.9 kB {0} [built]
   [60] (webpack)-dev-server/~/sockjs-client/lib/shims.js 18.2 kB {0} [built]
   [61] (webpack)-dev-server/~/sockjs-client/lib/utils/escape.js 2.31 kB {0} [built]
   [62] (webpack)-dev-server/~/sockjs-client/lib/utils/transport.js 1.35 kB {0} [built]
   [63] (webpack)-dev-server/~/sockjs-client/lib/utils/log.js 450 bytes {0} [built]
   [64] (webpack)-dev-server/~/sockjs-client/lib/event/event.js 477 bytes {0} [built]
   [65] (webpack)-dev-server/~/sockjs-client/lib/location.js 177 bytes {0} [built]
   [66] (webpack)-dev-server/~/sockjs-client/lib/event/close.js 295 bytes {0} [built]
   [67] (webpack)-dev-server/~/sockjs-client/lib/event/trans-message.js 292 bytes {0} [built]
   [68] (webpack)-dev-server/~/sockjs-client/lib/info-receiver.js 2.22 kB {0} [built]
   [69] (webpack)-dev-server/~/sockjs-client/lib/transport/sender/xhr-fake.js 456 bytes {0} [built]
   [70] (webpack)-dev-server/~/sockjs-client/lib/info-iframe.js 1.52 kB {0} [built]
   [71] (webpack)-dev-server/~/sockjs-client/lib/info-iframe-receiver.js 791 bytes {0} [built]
   [72] (webpack)-dev-server/~/sockjs-client/lib/info-ajax.js 1.03 kB {0} [built]
   [73] (webpack)-dev-server/~/sockjs-client/lib/iframe-bootstrap.js 2.9 kB {0} [built]
   [74] (webpack)-dev-server/~/sockjs-client/lib/facade.js 723 bytes {0} [built]
   [75] (webpack)/hot/dev-server.js 1.85 kB {0} [built]
   [76] (webpack)/hot/log-apply-result.js 813 bytes {0} [built]

ERROR in ./scripts/index.js
Module build failed: Error: Couldn't find preset "react" relative to directory "/home/xtd8865/data/projects/reactjs/es6-template/template"
    at /home/xtd8865/data/projects/reactjs/es6-template/template/node_modules/babel-core/lib/transformation/file/options/option-manager.js:298:19
    at Array.map (native)
    at OptionManager.resolvePresets (/home/xtd8865/data/projects/reactjs/es6-template/template/node_modules/babel-core/lib/transformation/file/options/option-manager.js:269:20)
    at OptionManager.mergePresets (/home/xtd8865/data/projects/reactjs/es6-template/template/node_modules/babel-core/lib/transformation/file/options/option-manager.js:258:10)
    at OptionManager.mergeOptions (/home/xtd8865/data/projects/reactjs/es6-template/template/node_modules/babel-core/lib/transformation/file/options/option-manager.js:243:14)
    at OptionManager.init (/home/xtd8865/data/projects/reactjs/es6-template/template/node_modules/babel-core/lib/transformation/file/options/option-manager.js:373:12)
    at File.initOptions (/home/xtd8865/data/projects/reactjs/es6-template/template/node_modules/babel-core/lib/transformation/file/index.js:221:65)
    at new File (/home/xtd8865/data/projects/reactjs/es6-template/template/node_modules/babel-core/lib/transformation/file/index.js:141:24)
    at Pipeline.transform (/home/xtd8865/data/projects/reactjs/es6-template/template/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at transpile (/home/xtd8865/data/projects/reactjs/es6-template/template/node_modules/babel-loader/index.js:38:20)
 @ multi main
webpack: bundle is now VALID.

/scripts/index.js没有任何反应参考:

var container = document.getElementById('root');

container.innerHTML = "THIS IS A TEST";

我已经从package.json和软件包的升级版本号中删除了名称中包含react的所有软件包:

{
  "name": "ES6-template",
  "version": "0.0.1",
  "description": "My es6 playground",
  "main": "index.js",
  "scripts": {
    "start": "node server.js",
    "build": "BABEL_ENV=production ./node_modules/.bin/webpack --config webpack.config.production.js",
    "lint": "./node_modules/.bin/eslint ."
  },
  "keywords": [
    "es6",
    "babel",
    "webpack"
  ],
  "dependencies": {
    "babel-runtime": "^6.9.2",
    "bootstrap": "^3.3.7"
  },
  "devDependencies": {
    "babel-polyfill": "^6.16.0",          
    "babel-core": "^6.16.0",
    "babel-eslint": "^7.0.0",
    "babel-loader": "^6.2.5",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-preset-es2015": "^6.16.0",
    "babel-preset-stage-0": "^6.16.0",
    "css-loader": "^0.25.0",
    "eslint": "^3.7.1",
    "file-loader": "^0.9.0",
    "url-loader": "^0.5.7",
    "webpack": "^1.13.2",
    "webpack-dev-server": "^1.16.2"
  }
}

请指教。另外,上面还有其他任何特定反应的包,没有反应就不需要吗?

1 个答案:

答案 0 :(得分:0)

我发现它是什么。问题出在隐藏文件.babelrc

我删除了参考,以便在那里做出反应,一切都很好。