ReferenceError: JSENCRYPT_VERSION is not defined after JSEncrypt 3.0.0 - javascript

I was using jsencrypt 3.0.0-rc.1 and updated to 3.0.0 just now. Now I am having a following error.
Uncaught ReferenceError: JSENCRYPT_VERSION is not defined.
Temporary Solution
: I could get rid of that error by replacing import JSEncrypt from 'jsencrypt' with import JSEncrypt from 'jsencrypt/bin/jsencrypt.min.js'
Found via GitHub
Question:
Is there any cleaner solution to this or just have to wait for good fix by the author?

Just update to the 3.0.1 and you are good to go. No more hacks needed.

Related

How can I resolve a TypeError using old version of ember and ember-light-table?

I have the test project at https://github.com/ericg-ember-questions/test_computed_sort
I setup the project by doing the following:
Node version: v12.18.1 (npm v6.14.5)
npm install --save-dev ember-cli#3.4
./node_modules/.bin/ember new test_computed_sort
cd test_computed_sort/
./node_modules/.bin/ember install ember-light-table#1.13.2
./node_modules/.bin/ember generate component test-comp
./node_modules/.bin/ember serve
application.hbs
{{test-comp}}
test-comp.hbs
Hello
{{#light-table}}
{{/light-table}}
If I comment out the reference to light-table, no error is generated. However, with it, I see in the console:
media.js:15 Uncaught TypeError: decorator is not a function
at media.js:15:1
at Array.reduce (<anonymous>)
at _applyDecoratedDescriptor (media.js:15:1)
at Module.callback (media.js:240:1)
at Module.exports (loader.js:106:1)
at Module._reify (loader.js:143:1)
at Module.reify (loader.js:130:1)
at Module.exports (loader.js:104:1)
at requireModule (loader.js:27:1)
at Class._extractDefaultExport (index.js:432:1)
What can I do to resolve this error so I can use ember-light-table with this project?
The error kinda hints at this, but it doesn't really make sense unless you're using modern ember -- but you're using 3.4 (thanks for providing that information!!)
The stack in your error is actually very helpful, and here's how you can figure out what the issue is.
I downloaded your reproduction repo (thanks for providing that! reproductions are immensely helpful in debugging!)
I got the same error you did:
The key piece here is the media.js reference.
Clicking into that we see:
that the compiled version of the ember-responsive/services/media file is using decorators --
you have some version of ember-responsive in your app which has decorators.
I saw in your package.json that you're specifying on alder version:
"ember-responsive": "^4.0.2",
this v4 version of ember-responsive only supports ember 3.13 and higher.
Kinda poking around the ember-responsive github, https://github.com/freshbooks/ember-responsive/blob/v3.0.5/config/ember-try.js
I see that the v3 series of ember-responsive supports back to Ember 2.12 -- definitely before decorators before supported.
So downgrading ember-responsive and restarting the app reveals this error:
"Assertion Failed: [ember-light-table] table must be an instance of Table"
this error is documented here: https://github.com/adopted-ember-addons/ember-light-table/issues/726
so it looks like some APIs usage issue.
If you want help figuring that out, feel free to post another question.

Lazyload polyfill / Magneto 2 js error "loading-attribute-polyfill.js Uncaught ReferenceError: module is not defined"

I am trying to load this lazyload polyfill script into my Magneto 2 project.
The code works but there is a console error I am trying to fix and having no luck.
Chrome console:
loading-attribute-polyfill.js Uncaught ReferenceError: module is not defined
at loading-attribute-polyfill.js:263
Safari console:
ReferenceError: Can't find variable: module
I have tried loading it in the head via xml, manually before end in a phtml template, and also through requirejs-config.js, all give the same error.
In case it matters I was loading it via requirejs like this:
var config = {
deps: [
"js/vendor/loading-attribute-polyfill"
],
map: { ... }
};
Has anyone implemented this script into magento 2 without this error? Is there a manual edit I can make to the script to workaround this?
Cheers!!
Which version of this polyfil are you trying to use? There are many versions https://github.com/mfranzke/loading-attribute-polyfill/tree/master/dist
The UMD one looks to be RequireJS compatible, but will probably need changes in the config.
#DamianDziaduch after replying to your comment I tried using the UMD version again via requireconfig.js 'deps' and it does work, console error gone, must have been caching or something when I tried before 🤷‍♀️ thanks for the tip!
Now I know to use UMD javascript where possible in magento2/requirejs (I did not come across this info when Googling!) 👍😎👍

TypeError: Restivus is not a constructor in Vulcan project

I have tried to add the meteor package nimble:restivus to my Vulcan project (which runs on meteor). When I add the following code:
import {Restivus} from 'meteor/nimble:restivus'
var Api = new Restivus ({
useDefaultAuth: true,
prettyJson: true,
});
export default Api
I get the error TypeError: Restivus is not a constructor when i build my app. I have tried adding the older version according to this: https://github.com/kahmali/meteor-restivus/issues/290 but still no luck. If i remove the curly brackets from import {Restivus}, still no luck. Spent days trying to figure this out, does anyone know how to solve this?
To anyone else that has this problem, I have spoken to the Vulcan team and there are a number of meteor packages that don't work with Vulcan. Don't ask me how many or which ones, as they didn't specify and I'm not sure why they don't work. I was told however, that npm packages are preferred, so you should use these over meteor packages if possible.

Uncaught SyntaxError in jquery.d.ts file

I'm trying to transition my jQuery project into a Typescript project. However, when I include the jQuery typings from the DefinitelyTyped Github using this method:
///<reference path="../../typings/jquery.d.ts"/>
I get "Uncaught SyntaxError: Unexpected identifier" on line 27 of jquery.d.ts, shown below
declare module 'jquery' {
export = jQuery;
}
I've done a bunch of searching about this problem, but I can't seem to find any solutions to this problem. What am I doing wrong?
(I am using WebStorm as my IDE)
EDIT:
Ok, I followed some instructions below and installed the jQuery typings via the npm terminal. However, when I remove the ///reference import, I now get an error in Webstorm: TS2304 cannot find name '$'. However, the code compiles to js and can run in the browser fine. It's just annoying to have those errors in my console in Webstorm. Is there something I need to add to get Webstorm to recognize jQuery?
most recommended practice nowaday is instead of ///reference import, install separate type packages: https://www.npmjs.com/package/#types/jquery as devdependency. (and ensure you're using latest ts compiler supports this)

JavaScript error when importing a package

getting the following error when importing netscape.javascript
importClass(netscape.javascript)
org.mozilla.javascript.EcmaError: ReferenceError: "netscape" is not defined.
Trying to use javascript within applet to get access to cookies.
Using the following as an example to import required package
http://www.java2s.com/Code/Java/JDK-6/UsingJavaObjectsinJavaScript.htm
http://docs.oracle.com/javase/tutorial/deployment/applet/invokingJavaScriptFromApplet.html
Found out by trial and error.
It seems we need to prefix with Packages
importPackage(Packages.netscape.javascript);

Categories

Resources