Reactjs MeteorJS服务器渲染包只加载客户端使用的模块

Reactjs MeteorJS服务器渲染包只加载客户端使用的模块,reactjs,meteor,server-side,Reactjs,Meteor,Server Side,我有一个带有React前端的MeteorJS应用程序。我正在使用服务器渲染大气包在服务器端渲染我的组件。在使用调试应用程序之后 meteor--settings private/local-settings.json--exclude archs web.browser.legacy,web.cordova--inspect brk=49179 节点运行时似乎试图加载所有已安装的节点模块,包括那些仅在.meteor/local/build/programs/server/runtime.js中以

我有一个带有React前端的MeteorJS应用程序。我正在使用服务器渲染大气包在服务器端渲染我的组件。在使用调试应用程序之后

meteor--settings private/local-settings.json--exclude archs web.browser.legacy,web.cordova--inspect brk=49179

节点运行时似乎试图加载所有已安装的节点模块,包括那些仅在
.meteor/local/build/programs/server/runtime.js中以客户端代码导入的模块。由于这些模块是在服务器端加载的,而不是在web浏览器中加载的,因此引发了一个相当恼人的异常,即未定义窗口,这是有意义的,因为浏览器外部不存在窗口对象。我已经浏览了Meteor文档以及服务器渲染包,甚至使用调试器对其进行了检查,并试图找出加载该模块的位置和原因,因为该模块在服务器端代码中没有被使用。我卸载并重新安装了meteor,运行meteor reset以清除捆绑包缓存,删除了顶级节点模块文件夹以及所有锁定文件,并重新安装了这些软件包。然而,似乎没有什么能解决这个错误。我束手无策。(╯°□°)╯︵ ┻━┻

节点版本=>v12.16.1

=> Started proxy.
W20200809-14:54:22.710(-5)? (STDERR) Debugger listening on ws://127.0.0.1:49179/xxx-xxx
W20200809-14:54:22.741(-5)? (STDERR) For help, see: https://nodejs.org/en/docs/inspector
W20200809-14:54:22.741(-5)? (STDERR) Debugger attached.
W20200809-16:46:28.008(-5)? (STDERR) Waiting for the debugger to disconnect...
W20200809-16:46:28.075(-5)? (STDERR) /Users/tim/.meteor/packages/meteor-tool/.1.10.2.6hsx6.cly95j++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:280
W20200809-16:46:28.076(-5)? (STDERR)                        throw(ex);
W20200809-16:46:28.076(-5)? (STDERR)                        ^
W20200809-16:46:28.076(-5)? (STDERR) 
W20200809-16:46:28.076(-5)? (STDERR) ReferenceError: window is not defined
W20200809-16:46:28.077(-5)? (STDERR)     at Object.<anonymous> (/Users/tim/Timothy/personal_projects/LC/node_modules/lit-html/lib/shady-render.js:35:1)
W20200809-16:46:28.077(-5)? (STDERR)     at Module._compile (internal/modules/cjs/loader.js:1158:30)
W20200809-16:46:28.077(-5)? (STDERR)     at Module.Mp._compile (/Users/tim/Timothy/personal_projects/LC/.meteor/local/build/programs/server/runtime.js:50:23)
W20200809-16:46:28.077(-5)? (STDERR)     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
W20200809-16:46:28.077(-5)? (STDERR)     at Module.load (internal/modules/cjs/loader.js:1002:32)
W20200809-16:46:28.077(-5)? (STDERR)     at Module.Mp.load (/Users/tim/Timothy/personal_projects/LC/.meteor/local/build/programs/server/runtime.js:15:31)
W20200809-16:46:28.078(-5)? (STDERR)     at Function.Module._load (internal/modules/cjs/loader.js:901:14)
W20200809-16:46:28.078(-5)? (STDERR)     at Module.require (internal/modules/cjs/loader.js:1044:19)
W20200809-16:46:28.078(-5)? (STDERR)     at Module.moduleLink [as link] (/Users/tim/.meteor/packages/meteor-tool/.1.10.2.6hsx6.cly95j++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/reify/lib/runtime/index.js:52:22)
W20200809-16:46:28.078(-5)? (STDERR)     at Object.<anonymous> (/Users/tim/Timothy/personal_projects/LC/node_modules/lit-element/lit-element.js:1:13)
W20200809-16:46:28.078(-5)? (STDERR)     at Module._compile (internal/modules/cjs/loader.js:1158:30)
W20200809-16:46:28.078(-5)? (STDERR)     at Module.Mp._compile (/Users/tim/Timothy/personal_projects/LC/.meteor/local/build/programs/server/runtime.js:50:23)
W20200809-16:46:28.079(-5)? (STDERR)     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
W20200809-16:46:28.079(-5)? (STDERR)     at Module.load (internal/modules/cjs/loader.js:1002:32)
W20200809-16:46:28.079(-5)? (STDERR)     at Module.Mp.load (/Users/tim/Timothy/personal_projects/LC/.meteor/local/build/programs/server/runtime.js:15:31)
W20200809-16:46:28.079(-5)? (STDERR)     at Function.Module._load (internal/modules/cjs/loader.js:901:14)
W20200809-16:46:28.079(-5)? (STDERR)     at Module.require (internal/modules/cjs/loader.js:1044:19)
W20200809-16:46:28.080(-5)? (STDERR)     at require (internal/modules/cjs/helpers.js:77:18)
W20200809-16:46:28.080(-5)? (STDERR)     at Object.<anonymous> (/Users/tim/Timothy/personal_projects/LC/node_modules/filestack-adaptive/build/main/index.js:6:21)
W20200809-16:46:28.080(-5)? (STDERR)     at Module._compile (internal/modules/cjs/loader.js:1158:30)
W20200809-16:46:28.080(-5)? (STDERR)     at Module.Mp._compile (/Users/tim/Timothy/personal_projects/LC/.meteor/local/build/programs/server/runtime.js:50:23)
W20200809-16:46:28.080(-5)? (STDERR)     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.

window
不会显示在您正在显示的代码中。该代码的意义是什么?您可以显示引发错误的代码吗?我不知道服务器渲染包,但要渲染React服务器端,您可以使用它,这很有魅力。
window
不会显示在您正在显示的代码中。意义是什么代码的作用是什么?你能显示错误抛出的代码吗?我不知道服务器渲染包,但要在服务器端渲染React,你可以使用它,它就像一个符咒。
onPageLoad(sink => {
    const { host } = sink.request.headers;
    let { pathname } = sink.request.url;

    if (pathname) pathname = pathname.toLowerCase();

    const headerContent = getHeaderContent(host, pathname);

    if (headerContent) {
        headerContent.forEach(header => {
            sink.appendToHead(header);
        });
    }

    const firstPaint = getFirstPaintAssetUrl(pathname);

    try {
        if (firstPaint) {
            const firstPaintAsset = Assets.getText(firstPaint);
            sink.appendToBody(firstPaintAsset);
        }
    } catch (e) {
        console.error(e);
    }
});