Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ReferenceError: window is not defined " in Postman #3

Open
VipinMishra opened this issue Feb 11, 2020 · 3 comments
Open

"ReferenceError: window is not defined " in Postman #3

VipinMishra opened this issue Feb 11, 2020 · 3 comments

Comments

@VipinMishra
Copy link

Hi,
I am follow all the steps and try to use RSA encryption in postman but getting error "ReferenceError: window is not defined". Please help me to fix this issues.

Capture

@loveiset
Copy link
Owner

@VipinMishra did you build yourself or just use my existing script. If you build yourself remember modify umd to var as my description. Or you can download my existing forge.js and try again

@luowuzhe23
Copy link

Hello
I used the file you provided, but I still encountered the same problem.
this tip is also: ReferenceError: window is not defined
Can you help me?

Thanks

@crcass
Copy link

crcass commented Oct 19, 2021

I was having the same issue. Here's my solution:

  1. clone the forge repo https://github.com/digitalbazaar/forge.git
  2. add the package global to the cloned forge project npm i global --save-dev
  3. update the webpack.config.js, replacing 'umd' with 'var' as @loveiset has done and update the plugins to add global/window:
  const bundle = Object.assign({}, common, {
    mode: 'development',
    output: {
      path: path.join(__dirname, 'dist'),
      filename: info.filenameBase + '.js',
      library: info.library || '[name]',
      libraryTarget: info.libraryTarget || 'var'
    },
    plugins: [
      new webpack.ProvidePlugin({
        window: 'global/window',
      }),
    ]
  });
  if (info.library === null) {
    delete bundle.output.library;
  }
  if (info.libraryTarget === null) {
    delete bundle.output.libraryTarget;
  }

  // optimized and minified bundle
  const minify = Object.assign({}, common, {
    mode: 'production',
    output: {
      path: path.join(__dirname, 'dist'),
      filename: info.filenameBase + '.min.js',
      library: info.library || '[name]',
      libraryTarget: info.libraryTarget || 'var'
    },
    devtool: 'cheap-module-source-map',
    plugins: [
      new webpack.ProvidePlugin({
        window: 'global/window',
      }),
    ]
  });
  1. build the project npm run build. copy dist/forge.js to Postman

Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants