You can check if the code is running on the server or on the client side by checking if the module is not 'undefined' :
var isNode = typeof module !== 'undefined'
Then you can only proceed to the execution of this code on the client side:
if(!isNode){
However, you should always check if Storage defined before use, as not all browsers support it:
if(typeof(Storage) !== "undefined"){
Tmkvu
source share