Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js): ReferenceError: document is not defined


Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ReferenceError: document is not defined
    at insertStyleElement (E:\webs\test\node_modules\style-loader\dist\cjs.js!E:\webs\test\node_modules\css-loader\dist\cjs.js!E:\webs\test\node_modules\postcss-loader\src\index.js??ref--4-3!E:\webs\test\node_modules\stylus-loader\index.js!E:\webs\test\client\assets\styles\footer.styl:309:15)
    at addStyle (E:\webs\test\node_modules\style-loader\dist\cjs.js!E:\webs\test\node_modules\css-loader\dist\cjs.js!E:\webs\test\node_modules\postcss-loader\src\index.js??ref--4-3!E:\webs\test\node_modules\stylus-loader\index.js!E:\webs\test\client\assets\styles\footer.styl:424:13)
    at modulesToDom (E:\webs\test\node_modules\style-loader\dist\cjs.js!E:\webs\test\node_modules\css-loader\dist\cjs.js!E:\webs\test\node_modules\postcss-loader\src\index.js??ref--4-3!E:\webs\test\node_modules\stylus-loader\index.js!E:\webs\test\client\assets\styles\footer.styl:297:18)
    at module.exports.module.exports (E:\webs\test\node_modules\style-loader\dist\cjs.js!E:\webs\test\node_modules\css-loader\dist\cjs.js!E:\webs\test\node_modules\postcss-loader\src\index.js??ref--4-3!E:\webs\test\node_modules\stylus-loader\index.js!E:\webs\test\client\assets\styles\footer.styl:455:25)
    at Object.<anonymous> (E:\webs\test\node_modules\style-loader\dist\cjs.js!E:\webs\test\node_modules\css-loader\dist\cjs.js!E:\webs\test\node_modules\postcss-loader\src\index.js??ref--4-3!E:\webs\test\node_modules\stylus-loader\index.js!E:\webs\test\client\assets\styles\footer.styl:206:14)
    at __webpack_require__ (E:\webs\test\node_modules\style-loader\dist\cjs.js!E:\webs\test\node_modules\css-loader\dist\cjs.js!E:\webs\test\node_modules\postcss-loader\src\index.js??ref--4-3!E:\webs\test\node_modules\stylus-loader\index.js!E:\webs\test\client\assets\styles\footer.styl:21:30)
    at E:\webs\test\node_modules\style-loader\dist\cjs.js!E:\webs\test\node_modules\css-loader\dist\cjs.js!E:\webs\test\node_modules\postcss-loader\src\index.js??ref--4-3!E:\webs\test\node_modules\stylus-loader\index.js!E:\webs\test\client\assets\styles\footer.styl:85:18
    at Object.<anonymous> (E:\webs\test\node_modules\style-loader\dist\cjs.js!E:\webs\test\node_modules\css-loader\dist\cjs.js!E:\webs\test\node_modules\postcss-loader\src\index.js??ref--4-3!E:\webs\test\node_modules\stylus-loader\index.js!E:\webs\test\client\assets\styles\footer.styl:88:10)
    at Module._compile (E:\webs\test\node_modules\v8-compile-cache\v8-compile-cache.js:194:30)
    at evalModuleCode (E:\webs\test\node_modules\mini-css-extract-plugin\dist\loader.js:66:10)
    at E:\webs\test\node_modules\mini-css-extract-plugin\dist\loader.js:196:31
    at E:\webs\test\node_modules\webpack\lib\Compiler.js:343:11
    at E:\webs\test\node_modules\webpack\lib\Compiler.js:681:15
    at AsyncSeriesHook.eval [as callAsync] (eval at create (E:\webs\test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
    at AsyncSeriesHook.lazyCompileHook (E:\webs\test\node_modules\tapable\lib\Hook.js:154:20)
    at E:\webs\test\node_modules\webpack\lib\Compiler.js:678:31
    at AsyncSeriesHook.eval [as callAsync] (eval at create (E:\webs\test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (E:\webs\test\node_modules\tapable\lib\Hook.js:154:20)
    at E:\webs\test\node_modules\webpack\lib\Compilation.js:1423:35
    at AsyncSeriesHook.eval [as callAsync] (eval at create (E:\webs\test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (E:\webs\test\node_modules\tapable\lib\Hook.js:154:20)
    at E:\webs\test\node_modules\webpack\lib\Compilation.js:1414:32
    at eval (eval at create (E:\webs\test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:11:1)
    at E:\webs\test\node_modules\terser-webpack-plugin\dist\index.js:321:9
    at TaskRunner.run (E:\webs\test\node_modules\terser-webpack-plugin\dist\TaskRunner.js:48:7)
    at TerserPlugin.optimizeFn (E:\webs\test\node_modules\terser-webpack-plugin\dist\index.js:227:18)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (E:\webs\test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:7:1)
    at AsyncSeriesHook.lazyCompileHook (E:\webs\test\node_modules\tapable\lib\Hook.js:154:20)
    at E:\webs\test\node_modules\webpack\lib\Compilation.js:1409:36
    at AsyncSeriesHook.eval [as callAsync] (eval at create (E:\webs\test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (E:\webs\test\node_modules\tapable\lib\Hook.js:154:20)
    at E:\webs\test\node_modules\webpack\lib\Compilation.js:1405:32
    at AsyncSeriesHook.eval [as callAsync] (eval at create (E:\webs\test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (E:\webs\test\node_modules\tapable\lib\Hook.js:154:20)
    at Compilation.seal (E:\webs\test\node_modules\webpack\lib\Compilation.js:1342:27)

 搞了一個下午,原來是加多了style-loader

{
    test: /\.styl$/,
    use: [
      MiniCssExtractPlugin.loader,
      'style-loader', //要刪除這個loader,不然一直報錯
      'css-loader',
      {
        loader: 'postcss-loader',
        options: {
          sourceMap: true
        }
      },
      'stylus-loader'
    ]
  }

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM