请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

webpack-dev-server 配置 : 执行npm run dev:client时报错

.16299.431]

(c) 2017 Microsoft Corporation。保留所有权利。


D:\WebStormWorkSpace\react-cnode-teach>npm run dev:client


> react-cnode-teach@1.0.0 dev:client D:\WebStormWorkSpace\react-cnode-teach

> cross-env NODE_ENV=development webpack-dev-server --config build/webpack.config.

client.js


i 「wds」: Project is running at http://localhost:8080/

i 「wds」: webpack output is served from /

× 「wdm」: Hash: c4019cc1ca7bd3931185

Version: webpack 4.8.3

Time: 465ms

Built at: 2018-05-24 09:19:15

 1 asset

Entrypoint main = main.js

 [3] (webpack)/hot/emitter.js 77 bytes {0} [built]

 [5] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {0} [built]

 [8] ./node_modules/html-entities/index.js 231 bytes {0} [built]

 [9] ./node_modules/ansi-html/index.js 4.16 KiB {0} [built]

[10] (webpack)-dev-server/client/overlay.js 3.58 KiB {0} [built]

[11] ./node_modules/sockjs-client/dist/sockjs.js 176 KiB {0} [built]

[12] (webpack)-dev-server/client/socket.js 1.05 KiB {0} [built]

[13] ./node_modules/loglevel/lib/loglevel.js 7.68 KiB {0} [built]

[14] (webpack)-dev-server/node_modules/ansi-regex/index.js 135 bytes {0} [built]

[15] (webpack)-dev-server/node_modules/strip-ansi/index.js 161 bytes {0} [built]

[18] ./node_modules/querystring-es3/index.js 127 bytes {0} [built]

[19] ./node_modules/url/util.js 314 bytes {0} [built]

[22] ./node_modules/url/url.js 22.8 KiB {0} [built]

[23] (webpack)-dev-server/client?http://localhost:8080 7.75 KiB {0} [built]

[24] multi (webpack)-dev-server/client?http://localhost:8080 ./src 40 bytes {0} [b

uilt]

    + 10 hidden modules


WARNING in configuration

The 'mode' option has not been set, webpack will fallback to 'production' for this

 value. Set 'mode' option to 'development' or 'production' to enable defaults for

each environment.

You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/


ERROR in multi (webpack)-dev-server/client?http://localhost:8080 ./src

Module not found: Error: Can't resolve './src' in 'D:\WebStormWorkSpace\react-cnode-teach'

 @ multi (webpack)-dev-server/client?http://localhost:8080 ./src

i 「wdm」: Failed to compile.



正在回答

1回答

webpack配置里面没有设置mode,开发时要设置为development,主要原因是你用的webpack版本是webpack4,课程视频是webpack3

0 回复 有任何疑惑可以回复我~
  • 提问者 慕粉西城 #1
    谢谢老师 麻烦老师给看一下 我安装mode的时候报错:added 71 packages, removed 1 package and updated 7 packages in 34.883s
    { Error: Cannot find module 'webpack-cli'
        at Function.Module._resolveFilename (module.js:485:15)
        at Function.Module._load (module.js:437:25)
        at Module.require (module.js:513:17)
        at require (internal/module.js:11:18)
        at runCommand.then.result (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:62:14)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:188:7) code: 'MODULE_NOT_FOUND' }
    回复 有任何疑惑可以回复我~ 2018-05-24 11:57:13
  • Jokcy 回复 提问者 慕粉西城 #2
    安装mode?mode只是一个webpack的配置而已。。。
    回复 有任何疑惑可以回复我~ 2018-05-25 14:37:38
  • 提问者 慕粉西城 回复 Jokcy #3
    那老师我这边是不是需要删掉webpack4  安装webpack3啊
    回复 有任何疑惑可以回复我~ 2018-05-26 09:41:20
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信