From e06ad55eb2d20133b7c8cbedd764b30bcbd04ad0 Mon Sep 17 00:00:00 2001 From: Michael James Date: Mon, 15 Jul 2024 15:33:10 -0400 Subject: [PATCH] Fixes #2250 - Add check that code is running in a browser before adding devtools --- src/store.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/store.js b/src/store.js index 3ae6898f9..d6a6c5181 100644 --- a/src/store.js +++ b/src/store.js @@ -12,6 +12,8 @@ import { unifyObjectStyle } from './store-util' +const isBrowser = typeof document !== 'undefined' + export function createStore (options) { return new Store(options) } @@ -73,9 +75,9 @@ export class Store { app.provide(injectKey || storeKey, this) app.config.globalProperties.$store = this - const useDevtools = this._devtools !== undefined + const useDevtools = (this._devtools !== undefined ? this._devtools - : __DEV__ || __VUE_PROD_DEVTOOLS__ + : __DEV__ || __VUE_PROD_DEVTOOLS__) && isBrowser if (useDevtools) { addDevtools(app, this)