travist / jsencrypt

A zero-dependency Javascript library to perform OpenSSL RSA Encryption, Decryption, and Key Generation.
http://www.travistidwell.com/jsencrypt
Other
6.68k stars 2.02k forks source link

ERROR in ./node_modules/jsencrypt/lib/index.js 1:0-40 #270

Closed ashokram closed 1 year ago

ashokram commented 2 years ago

Hi, getting error with the latest version "3.3.0" in React, this is working fine with the previous version 3.2.1

Thank you.

Error

nathansbird commented 2 years ago

Having the same issue. Reverting the version is the only solution I've found so far. @travist, is this something you can investigate?

litt1e-p commented 2 years ago

same error

aak1247 commented 2 years ago

Please do not make breaking change in patch version 😥

jdsalasca commented 2 years ago

Hi everyone I have find as a temporary solution is to change the version of jsencrypt to "jsencrypt": "^3.0.0-rc.1", that can fix the problem

The problem is because of webpack5 have change the way it builds the project dependencies.

Have a good day

promise96319 commented 2 years ago

This config will solve the problem.

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.m?js$/,
        resolve: {
          fullySpecified: false, // disable the behaviour
        },
      },
    ],
  },
};

When package.json contains a field of "type" with the value of "module" , webpack requires a full path(including the file extension, like .js/.mjs),otherwise webpack would fail the compiling with a Module not found error. Setting fullySpecified to false disables this behavior.

You can check it at Webpack docs.

jonasvoelcker commented 2 years ago

For me this just looks like a small patch and no solution, additionally we don't have an appropriate loader for this config. The problem still exists with the new version 3.3.1 😉

whitetrefoil commented 2 years ago

It seems the tsconfig not set to output an ESM. So the generated JS files import without the ".js" extname.

wxf1024 commented 1 year ago

NOT A GOOD PRACTICE:

just

import 'jsencrypt/bin/jsencrypt'

and you have a global JSEncrypt.
using it anywhere:

const enc = new JSEncrypt()
dj49846917 commented 1 year ago

How to solve this problem in umijs and how to configure it on chainWebpack!

travist commented 1 year ago

Please try 3.3.2 and see if it fixes this issue.