2017-09-04 178 views
0

當我嘗試運行npm run dev時,出現此錯誤。這是一個全新的安裝,並且我在另一個文件夾中使用相同的設置。我在另一臺電腦上遇到同樣的錯誤。Laravel npm run dev返回TypeError:chunk.sortModules不是函數

版本 NPM:5.3.0 節點:V8.4.0

test ⚑ → npm run dev                                                              master ✗ 2d 

> @ dev /Users/myuser/Code/testing/test 
> node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js 

78% advanced chunk optimization/Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:188 
      chunk.sortModules(); 
       ^

TypeError: chunk.sortModules is not a function 
    at /Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:188:19 
    at /Users/myuser/Code/testing/test/node_modules/async/dist/async.js:3083:16 
    at eachOfArrayLike (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:1003:9) 
    at eachOf (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:1051:5) 
    at Object.eachLimit (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:3145:5) 
    at Compilation.<anonymous> (/Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:184:27) 
    at Compilation.applyPluginsAsyncSeries (/Users/myuser/Code/testing/test/node_modules/tapable/lib/Tapable.js:206:13) 
    at Compilation.seal (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:579:8) 
    at /Users/myuser/Code/testing/test/node_modules/webpack/lib/Compiler.js:493:16 
    at /Users/myuser/Code/testing/test/node_modules/tapable/lib/Tapable.js:289:11 
    at _addModuleChain (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:481:11) 
    at processModuleDependencies.err (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:452:13) 
    at _combinedTickCallback (internal/process/next_tick.js:131:7) 
    at process._tickCallback (internal/process/next_tick.js:180:9) 
npm ERR! code ELIFECYCLE 
npm ERR! errno 1 
npm ERR! @ dev: `node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the @ dev script. 
npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 

npm ERR! A complete log of this run can be found in: 
npm ERR!  /Users/myuser/.npm/_logs/2017-09-04T13_55_30_770Z-debug.log 

回答

0

這爲我工作。當我用紗線代替。

rm -rf node_modules 
brew install yarn 
yarn 
yarn run dev 
3

的問題似乎在包中,涉及到的區別就在今天我正在更新webapacker 3版這在Rails應用程序使用的WebPack版本3和我得到同樣的錯誤。當我將這個包更新到package.json文件中的這個版本時,問題停止了: "sass-loader": "^6.0.6" "babel-loader": "7.1.2" "webpack": "^3.6.0" 感謝這個傢伙的建議:https://github.com/rails/webpacker/issues/852#issuecomment-331764386 我建議如果你使用這些包,你可以更改這些包來查看它是否工作爲你也。

+0

我也遇到同樣的問題,你的回答是正確的 – taryn