查看: 58|回覆: 0

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

[複製鏈接]

3

主題

0

回帖

0

積分

热心网友

金币
0
閲讀權限
220
精華
0
威望
0
贡献
0
在線時間
0 小時
註冊時間
2010-7-11
發表於 2020-9-2 09:41:00 | 顯示全部樓層 |閲讀模式
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'
    ]
  }

  

 



来源:https://www.cnblogs.com/baidei/p/13600094.html
回覆

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即注册

本版積分規則

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部