Vue: ssr: never used window but error window not defined

Created on 22 May 2017  路  3Comments  路  Source: vuejs/vue

Recently, after learing ssr I created a demo with router and without store.

Here is the link: here

I can generate Client Config and Server Config successfully.

But After I ran the server to access the router page, error occured,

[Vue warn]: Error in beforeCreate hook: "ReferenceError: window is not defined"

found in

---> <App> at /Users/work/IAPYANG/GitHub/learn-vue-ssr/src/App.vue
       <Root>
error during render : /
ReferenceError: window is not defined
    at main.js:178:9
    at main.js:167:46
    at module.exports.module.exports (~/style-loader/lib/addStyles.js:57:0)
    at Object.module.exports.module.exports.location (src/App.vue?3a9d:12:0)
    at __webpack_require__ (webpack:/webpack/bootstrap 837200b4ffb26030ef47:19:0)
    at VueComponent.injectStyle (src/App.vue:3:0)
    at VueComponent.hook (~/vue-loader/lib/component-normalizer.js:53:0)
    at callHook (/Users/work/IAPYANG/GitHub/learn-vue-ssr/node_modules/vue/dist/vue.runtime.common.js:2554:21)
    at VueComponent.Vue._init (/Users/work/IAPYANG/GitHub/learn-vue-ssr/node_modules/vue/dist/vue.runtime.common.js:3994:5)
    at new VueComponent (/Users/work/IAPYANG/GitHub/learn-vue-ssr/node_modules/vue/dist/vue.runtime.common.js:4167:12)

But I've never used window in App.vue.

How to solve this error and successfully access the page?

Thanks!

Most helpful comment

The default webpack style-loader is not isomorphic - use vue-style-loader instead.

All 3 comments

Hello, your issue has been closed because it does not conform to our issue requirements. Please use the Issue Helper to create an issue - thank you!

The default webpack style-loader is not isomorphic - use vue-style-loader instead.

@yyx990803
Thanks a lot! You're so quick!
I'll check if it helps.

ps: I don't have the chance to attend the vue meeting in Beijing. Is there any chance for me to access media like videos of the meeting?

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

6pm picture 6pm  路  3Comments

wufeng87 picture wufeng87  路  3Comments

gkiely picture gkiely  路  3Comments

franciscolourenco picture franciscolourenco  路  3Comments

julianxhokaxhiu picture julianxhokaxhiu  路  3Comments