Closed SabirHossain closed 4 years ago
I am also facing the same problem.
If I ams importing it as
import SecureLS from 'secure-ls'
, then it throws error
ReferenceError: localStorage is not defined at new SecureLS (C:\Users\Lui\Desktop\PO\purchase-order\frontend\node_modules\secure-ls\dist\secure-ls.js:130:16)
if importing import * as SecureLS from 'secure-ls'
then it throws
cannot import class as function
@softvar can you help ?
Hi,
This package assumes that localStorage is present. In the case of NextJs Server-side Rendering, localStorage is not defined as node has no in-built support.
You should use this to have localStorage in the node. And once it is globally defined, you can use this lib: secure-ls to have additional functionalities like encrypting and compressing the data.
PS:
import * as secureLs from 'secure-ls';
works as intended.
Please let me know if you have any further doubts.
I'm trying to use secure-ls with Angular 6 it working fine but I get the error on build log
import * as SecureLS from 'secure-ls'