运行npm run dev_win出错了
来源:4-2 通用JS工具类封装(网络数据请求功能)
qq_Fromnowon_2
2018-01-31
You may need an appropriate loader to handle this file type
mm.js
/*
* @Author: zyy
* @Date: 2018-01-31 16:12:13
* @Last Modified by: zyy
* @Last Modified time: 2018-01-31 17:00:39
*/
'use strict';
var _mm = {
request : function(param){
var _ this = this;
$.ajax({
type : param.method || 'get',
url : param.url || '',
daraType : param.type || 'json',
data : param.data || '',
success : function(res){
if( 0 === res.status){
//请求成功
typeof param.success === 'function' && param.success(res.data,res.msg)
}
//没有登录状态
else if( 10 === res.status){
_this.doLogin();
}
//请求数据错误
else if( 1 === res.status){
typeof param.error === 'function' && param.error(res.msg)
}
},
error : function(err){
typeof param.error === 'function' && param.error(res.statusText)
}
});
},
//统一登录处理
doLogin : function(){
window.location.href = './login.html?redirect='+encodeURIComponent(window.location.href);
}
}
module.exports = _mm;
index.js
'use strict';
require('./index.css');
var _mm = require('util/mm.js');
alert(123);
_mm.request({
url: './test.do',
success: function(res){
console.log(res);
},
error: function(errMsg){
console.log(errMsg);
},
});
这个也是配好了的
resolve :{
alias : {
util : __dirname + '/src/util',
page : __dirname + '/src/page',
service : __dirname + '/src/service',
image : __dirname + '/src/image'
}
},
2回答
-
qq_Fromnowon_2
提问者
2018-02-01
$ npm run dev_win
> demo-d1@1.0.0 dev_win C:\Users\zyy\Desktop\zyygit\doc\demo-d1
> set WEBPACK_ENV=dev && webpack-dev-server --inline --port 8080
http://localhost:8080/
webpack result is served from /dist
content is served from C:\Users\zyy\Desktop\zyygit\doc\demo-d1
Hash: 3efed8e691a858641e70
Version: webpack 1.15.0
Time: 3425ms
Asset Size Chunks Chunk Names
js/base.js 245 kB 0 [emitted] common
js/index.js 737 bytes 1 [emitted] index
js/login.js 704 bytes 2 [emitted] login
css/index.css 176 bytes 1 [emitted] index
view/index.html 520 bytes [emitted]
view/login.html 670 bytes [emitted]
chunk {0} js/base.js (common) 224 kB [rendered]
[0] multi common 40 bytes {0} [built]
[1] (webpack)-dev-server/client?http://localhost:8080 4.16 kB {0} [built]
[2] ./~/url/url.js 23.3 kB {0} [built]
[3] ./~/url/~/punycode/punycode.js 14.6 kB {0} [built]
[4] (webpack)/buildin/module.js 251 bytes {0} [built]
[5] ./~/url/util.js 314 bytes {0} [built]
[6] ./~/querystring/index.js 127 bytes {0} [built]
[7] ./~/querystring/decode.js 2.4 kB {0} [built]
[8] ./~/querystring/encode.js 2.09 kB {0} [built]
[9] ./~/strip-ansi/index.js 161 bytes {0} [built]
[10] ./~/ansi-regex/index.js 135 bytes {0} [built]
[11] (webpack)-dev-server/client/socket.js 897 bytes {0} [built]
[12] ./~/sockjs-client/lib/entry.js 244 bytes {0} [built]
[13] ./~/sockjs-client/lib/transport-list.js 613 bytes {0} [built]
[14] ./~/sockjs-client/lib/transport/websocket.js 2.72 kB {0} [built]
[15] ./~/process/browser.js 5.42 kB {0} [built]
[16] ./~/sockjs-client/lib/utils/event.js 2 kB {0} [built]
[17] ./~/sockjs-client/lib/utils/random.js 746 bytes {0} [built]
[18] ./~/sockjs-client/lib/utils/browser-crypto.js 438 bytes {0} [built]
[19] ./~/sockjs-client/lib/utils/url.js 975 bytes {0} [built]
[20] ./~/url-parse/index.js 11.5 kB {0} [built]
[21] ./~/requires-port/index.js 753 bytes {0} [built]
[22] ./~/url-parse/~/querystringify/index.js 1.51 kB {0} [built]
[23] ./~/debug/src/browser.js 4.73 kB {0} [built]
[24] ./~/debug/src/debug.js 4.39 kB {0} [built]
[25] ./~/ms/index.js 2.76 kB {0} [built]
[26] ./~/inherits/inherits_browser.js 672 bytes {0} [built]
[27] ./~/sockjs-client/lib/event/emitter.js 1.27 kB {0} [built]
[28] ./~/sockjs-client/lib/event/eventtarget.js 1.85 kB {0} [built]
[29] ./~/sockjs-client/lib/transport/browser/websocket.js 210 bytes {0} [built]
[30] ./~/sockjs-client/lib/transport/xhr-streaming.js 1.25 kB {0} [built]
[31] ./~/sockjs-client/lib/transport/lib/ajax-based.js 1.31 kB {0} [built]
[32] ./~/sockjs-client/lib/transport/lib/sender-receiver.js 1.18 kB {0} [built]
[33] ./~/sockjs-client/lib/transport/lib/buffered-sender.js 2.3 kB {0} [built]
[34] ./~/sockjs-client/lib/transport/lib/polling.js 1.32 kB {0} [built]
[35] ./~/sockjs-client/lib/transport/receiver/xhr.js 1.58 kB {0} [built]
[36] ./~/sockjs-client/lib/transport/sender/xhr-cors.js 343 bytes {0} [built]
[37] ./~/sockjs-client/lib/transport/browser/abstract-xhr.js 4.8 kB {0} [built]
[38] ./~/sockjs-client/lib/transport/sender/xhr-local.js 352 bytes {0} [built]
[39] ./~/sockjs-client/lib/utils/browser.js 560 bytes {0} [built]
[40] ./~/sockjs-client/lib/transport/xdr-streaming.js 984 bytes {0} [built]
[41] ./~/sockjs-client/lib/transport/sender/xdr.js 2.46 kB {0} [built]
[42] ./~/sockjs-client/lib/transport/eventsource.js 766 bytes {0} [built]
[43] ./~/sockjs-client/lib/transport/receiver/eventsource.js 1.58 kB {0} [built]
[44] ./~/sockjs-client/lib/transport/browser/eventsource.js 37 bytes {0} [built]
[45] ./~/sockjs-client/lib/transport/lib/iframe-wrap.js 981 bytes {0} [built]
[46] ./~/sockjs-client/lib/transport/iframe.js 3.83 kB {0} [built]
[47] ./~/json3/lib/json3.js 43.3 kB {0} [built]
[48] (webpack)/buildin/amd-options.js 43 bytes {0} [built]
[49] ./~/sockjs-client/lib/version.js 26 bytes {0} [built]
[50] ./~/sockjs-client/lib/utils/iframe.js 5.03 kB {0} [built]
[51] ./~/sockjs-client/lib/utils/object.js 532 bytes {0} [built]
[52] ./~/sockjs-client/lib/transport/htmlfile.js 710 bytes {0} [built]
[53] ./~/sockjs-client/lib/transport/receiver/htmlfile.js 2.2 kB {0} [built]
[54] ./~/sockjs-client/lib/transport/xhr-polling.js 894 bytes {0} [built]
[55] ./~/sockjs-client/lib/transport/xdr-polling.js 712 bytes {0} [built]
[56] ./~/sockjs-client/lib/transport/jsonp-polling.js 1.02 kB {0} [built]
[57] ./~/sockjs-client/lib/transport/receiver/jsonp.js 5.57 kB {0} [built]
[58] ./~/sockjs-client/lib/transport/sender/jsonp.js 2.46 kB {0} [built]
[59] ./~/sockjs-client/lib/main.js 11.9 kB {0} [built]
[60] ./~/sockjs-client/lib/shims.js 17.2 kB {0} [built]
[61] ./~/sockjs-client/lib/utils/escape.js 2.36 kB {0} [built]
[62] ./~/sockjs-client/lib/utils/transport.js 1.35 kB {0} [built]
[63] ./~/sockjs-client/lib/utils/log.js 450 bytes {0} [built]
[64] ./~/sockjs-client/lib/event/event.js 477 bytes {0} [built]
[65] ./~/sockjs-client/lib/location.js 177 bytes {0} [built]
[66] ./~/sockjs-client/lib/event/close.js 295 bytes {0} [built]
[67] ./~/sockjs-client/lib/event/trans-message.js 292 bytes {0} [built]
[68] ./~/sockjs-client/lib/info-receiver.js 2.22 kB {0} [built]
[69] ./~/sockjs-client/lib/transport/sender/xhr-fake.js 456 bytes {0} [built]
[70] ./~/sockjs-client/lib/info-iframe.js 1.52 kB {0} [built]
[71] ./~/sockjs-client/lib/info-iframe-receiver.js 791 bytes {0} [built]
[72] ./~/sockjs-client/lib/info-ajax.js 1.03 kB {0} [built]
[73] ./~/sockjs-client/lib/iframe-bootstrap.js 2.9 kB {0} [built]
[74] ./~/sockjs-client/lib/facade.js 723 bytes {0} [built]
[75] ./src/page/common/index.js 142 bytes {0} [built]
chunk {1} js/index.js, css/index.css (index) 320 bytes {0} [rendered]
[0] multi index 40 bytes {1} [built]
[76] ./src/page/index/index.js 239 bytes {1} [built] [1 error]
[77] ./src/page/index/index.css 41 bytes {1} [built]
chunk {2} js/login.js (login) 417 bytes {0} [rendered]
[0] multi login 40 bytes {2} [built]
[83] ./src/page/login/index.js 198 bytes {2} [built]
[84] ./src/page/module.js 179 bytes {2} [built]
ERROR in ./src/util/mm.js
Module parse failed: C:\Users\zyy\Desktop\zyygit\doc\demo-d1\src\util\mm.js Unexpected token (13:8)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (13:8)
at Parser.pp$4.raise (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:2221:15)
at Parser.pp.unexpected (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:603:10)
at Parser.pp.semicolon (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:581:61)
at Parser.pp$1.parseVarStatement (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:918:10)
at Parser.pp$1.parseStatement (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:706:19)
at Parser.pp$1.parseBlock (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:981:25)
at Parser.pp$3.parseFunctionBody (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:2105:24)
at Parser.pp$1.parseFunction (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:1065:10)
at Parser.pp$3.parseExprAtom (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:1810:19)
at Parser.pp$3.parseExprSubscripts (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:1715:21)
at Parser.pp$3.parseMaybeUnary (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:1692:19)
at Parser.pp$3.parseExprOps (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:1637:21)
at Parser.pp$3.parseMaybeConditional (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:1620:21)
at Parser.pp$3.parseMaybeAssign (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:1597:21)
at Parser.pp$3.parsePropertyValue (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:1998:89)
at Parser.pp$3.parseObj (C:\Users\zyy\Desktop\zyygit\doc\demo-d1\node_modules\acorn\dist\acorn.js:1989:14)
@ ./src/page/index/index.js 4:10-31
Child html-webpack-plugin for "view\login.html":
chunk {0} view/login.html 541 kB [rendered]
[0] ./~/html-webpack-plugin/lib/loader.js!./src/view/login.html 912 bytes {0} [built]
[1] ./~/lodash/lodash.js 540 kB {0} [built]
[2] (webpack)/buildin/module.js 251 bytes {0} [built]
Child html-webpack-plugin for "view\index.html":
chunk {0} view/index.html 541 kB [rendered]
[0] ./~/html-webpack-plugin/lib/loader.js!./src/view/index.html 670 bytes {0} [built]
[1] ./~/lodash/lodash.js 540 kB {0} [built]
[2] (webpack)/buildin/module.js 251 bytes {0} [built]
[3] ./~/html-loader!./src/view/layout/html-head.html 121 bytes {0} [built]
Child extract-text-webpack-plugin:
chunk {0} extract-text-webpack-plugin-output-filename 2.62 kB [rendered]
[0] ./~/css-loader!./src/page/index/index.css 363 bytes {0} [built]
[1] ./~/css-loader/lib/css-base.js 2.26 kB {0} [built]
webpack: Failed to compile.
012018-02-01 -
Rosen
2018-02-01
把报错信息再粘一下,有可能是语法错误
022018-02-02
相似问题