javascript - 'CommonsChunkPlugin 現在只需要一個參數。。。。
巴扎黑
巴扎黑 2017-05-16 13:43:17
0
4
648

#
Error: Deprecation notice: CommonsChunkPlugin now only takes a single argument. Either an options
object *or* the name of the chunk.
Example: if your old code looked like this:
        new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js')
You would change it to:
        new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.bundle.js' })
The available options are:
        name: string
        names: string[]
        filename: string
        minChunks: number
        chunks: string[]
        children: boolean
        async: boolean
        minSize: number
    at new CommonsChunkPlugin (E:\heShengWeb\manta-web\node_modules\webpack\lib\optimize\CommonsChunkPlugin.js:10:10)
    at Object.<anonymous> (E:\heShengWeb\manta-web\webpack\base.config.js:82:9)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (E:\heShengWeb\manta-web\webpack\webpack.build.config.js:5:18)

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "E:\Software\Nodejs\node.exe" "E:\Software\Nodejs\node_global\node_modules\npm\bin\npm-cli.js" "run" "build"
npm ERR! node v6.3.0
npm ERR! npm  v3.8.0
npm ERR! code ELIFECYCLE
npm ERR! mantaweb@1.0.0 build: `webpack --config webpack/webpack.build.config.js --progress --colors`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mantaweb@1.0.0 build script 'webpack --config webpack/webpack.build.config.js --progress --colors'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the mantaweb package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack --config webpack/webpack.build.config.js --progress --colors
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs mantaweb
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls mantaweb
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     E:\heShengWeb\manta-web\npm-debug.log

的確我的CommonsChunkPlugin配置是他報的錯的樣子,但是我在公司的電腦上這樣配不會錯,怎麼回到家裡自己的電腦就會報這個錯了,改怎麼解決呢(我不太想改這個配置的)?

巴扎黑
巴扎黑

全部回覆(4)
过去多啦不再A梦

不要使用webpack2.x,公司使用的設定應該是webpack1.x,2.x的設定和1.x不一樣,你看下你電腦的webpack版本吧,看看不是2.x的

淡淡烟草味

CommonsChunkPlugin
版本更新了,不再支持原來的傳參方式
而且應該很久以前的事了...

而且報錯訊息裡都給改法了:

new webpack.optimize.CommonsChunkPlugin({ 
    name: 'vendor', 
    filename: 'vendor.bundle.js', 
    minChunks: Infinity 
})
左手右手慢动作

換一個版本的函式庫就好了,你公司上用什麼版本,這裡就用什麼版本就好了。

小葫芦

要嘛把webpack更新到2.x,要嘛就回到webpack1.x。因為你公司用的舊版,所以說為了保持一致性。建議你改成1.x,這樣也方便你的程式碼一致性。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!