Webpack breaks when i include node-rsa library - json

When I try to include the node-rsa library with Webpack, as so:
import NodeRSA from 'node-rsa';
I get the following error:
ERROR in ./~/constants-browserify/constants.json
Module parse failed: /home/hencic00/Dropbox/Documents/Camelot/node_modules/constants-browserify/constants.json Unexpected token (2:12)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:12)
at Parser.pp$4.raise (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:2221:15)
at Parser.pp.unexpected (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:603:10)
at Parser.pp.semicolon (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:581:61)
at Parser.pp$1.parseExpressionStatement (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:966:10)
at Parser.pp$1.parseStatement (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:730:24)
at Parser.pp$1.parseBlock (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:981:25)
at Parser.pp$1.parseStatement (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:709:33)
at Parser.pp$1.parseTopLevel (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:638:25)
at Parser.parse (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:516:17)
at Object.parse (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:3098:39)
at Parser.parse (/home/hencic00/Dropbox/Documents/Camelot/node_modules/webpack/lib/Parser.js:902:15)
at DependenciesBlock.<anonymous> (/home/hencic00/Dropbox/Documents/Camelot/node_modules/webpack/lib/NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (/home/hencic00/Dropbox/Documents/Camelot/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
at nextLoader (/home/hencic00/Dropbox/Documents/Camelot/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
at /home/hencic00/Dropbox/Documents/Camelot/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
at Storage.finished (/home/hencic00/Dropbox/Documents/Camelot/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
at /home/hencic00/Dropbox/Documents/Camelot/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
# ./~/node-rsa/src/NodeRSA.js 10:16-36
There doesn't seem to be any existing questions on this topic.
Any ideas?

Just add json loader to your webpack config.

Related

Dashboard ninja trace back error when open configuration

in Odoo 13, I am facing this error when open configuration in Dashboard ninja:
SyntaxError: Unexpected token F in JSON at position 0
at JSON.parse (<anonymous>)
at Class.init (http://localhost:8069/web/content/329-72f1291/web.assets_backend.js:2478:363)
at Class.init (http://localhost:8069/web/content/329-72f1291/web.assets_backend.js:2479:328)
at Class.init (http://localhost:8069/web/content/319-8bc33a0/web.assets_common.js:3864:371)
at new Class (http://localhost:8069/web/content/319-8bc33a0/web.assets_common.js:3862:65)
at Class._createViewController (http://localhost:8069/web/content/329-72f1291/web.assets_backend.js:442:658)
at http://localhost:8069/web/content/329-72f1291/web.assets_backend.js:447:169
Can you help?

Json data not get in terminal & get error->(SyntaxError: Unexpected end of JSON input)

I am trying to get some value from Youtube Api. Now, My express code is->
https.get("https://www.googleapis.com/youtube/v3/videos?part=snippet&id=qW_SWM1wpMA&key=MYAPIKEY",function(res){
res.on("data",function(data){
const da=JSON.parse(data);
console.log(da);
})
});
Now, I am console log the data what's coming from api. But I get this error->
$ node app.js
Port is running
undefined:13
"description": "\"Bang Bhaja\" shows how Nonte and Fonte makes a trick to punish Keltu for punishing them from Superintendent Sir for eating the Ilish Maach.\n\nNonte Fonte is a Bengali comic-strip creation of Narayan Debnath which originally was serialized for the childre
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at IncomingMessage.<anonymous> (C:\Users\LENOVO\Desktop\youtube\app.js:13:19)
at IncomingMessage.emit (events.js:314:20)
at IncomingMessage.Readable.read (_stream_readable.js:514:10)
at flow (_stream_readable.js:987:34)
at resume_ (_stream_readable.js:968:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
But when paste the API link (what's mention in above in https.get method) in chrome I get the json data successfully. Then why not i getting the json data in terminal?

Re-frame dispatches and subscribes not working in the repl and test files

I have a re-frame project, and my events, subs and db cljs files are populated. I use these three in my project and it works well. But I created a test file, and called subscribe and dispatch in it like so:
(deftest category-filter-test
(dispatch [:add-filter "cat"])
(is (= #(subscribe [:filters]) ["cat"]))
)
And that doesn't work. I get
#object[Error Error: No protocol method IDeref.-deref defined for type undefined: ]
On the other hand, if I try to run subscribe in the shadow-cljs repl, I get the following error:
------ WARNING - :undeclared-ns ------------------------------------------------
Resource: :1:2
No such namespace: user, could not locate user.cljs, user.cljc, or JavaScript source providing "user"
--------------------------------------------------------------------------------
------ WARNING - :undeclared-var -----------------------------------------------
Resource: :1:2
Use of undeclared Var user/start
--------------------------------------------------------------------------------
ReferenceError: user is not defined
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.browser.js), <anonymous>:1:1)
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.browser.js:758:16)
at eval (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.browser.js:767:44)
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.env.js:167:108)
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.browser.js:766:46)
at shadow$cljs$devtools$client$browser$handle_message (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.browser.js:844:37)
at eval (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.env.js:307:151)
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.env.js:289:90)
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.env.js:310:40)
How to fix these two errors?

json.parse works in js but not in angular ts

I am re-writing an existing js app into angular and ts. I have a json data file that I read as part of the startup of the existing js app and it works fine. When I try and read the exact same file with the exact same line of code in angular, ts/angular barfs all over it. Here is the code from the existing app:
aircraftData = JSON.parse(data);
and the console log is empty. Here is the the code from the new angular version of the app:
const content = require('./shared/imeiXref.json');
console.log("IMEI=",content[0].IMEI);
and the console output:
AppComponent_Host.ngfactory.js? [sm]:1 ERROR SyntaxError: Unexpected token o in JSON at position 1
at JSON.parse (<anonymous>)
at AppComponent.push../src/app/app.component.ts.AppComponent.ngOnInit (app.component.ts:33)
at checkAndUpdateDirectiveInline (core.js:22089)
at checkAndUpdateNodeInline (core.js:23353)
at checkAndUpdateNode (core.js:23315)
at debugCheckAndUpdateNode (core.js:23949)
at debugCheckDirectivesFn (core.js:23909)
at Object.eval [as updateDirectives] (AppComponent_Host.ngfactory.js? [sm]:1)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:23901)
at checkAndUpdateView (core.js:23297)
View_AppComponent_Host_0 # AppComponent_Host.ngfactory.js? [sm]:1
proxyClass # compiler.js:18234
push../node_modules/#angular/core/fesm5/core.js.DebugContext_.logError #
core.js:24129
push../node_modules/#angular/core/fesm5/core.js.ErrorHandler.handleError # core.js:15762
(anonymous) # core.js:18116
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke #
zone.js:391
.....
Is JSON expected to be in a different format from js to angular/ts?
Thanks....
It was actually already working. I didn't realize that when I read the file in I was already able to parse the JSON by field name so I don't even need to run JSON.parse.

Invalid mapping while running gulp

im trying to run gulp in node console and I get an error like below. I was looking over the net for a solution, but nothing has work so far. Hope you can help me.
C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\source-map\lib\source-map-generator.js:298
throw new Error('Invalid mapping: ' + JSON.stringify({
^
Error: Invalid mapping: {"generated":{"line":157,"column":3},"source":"../bower_components/bootstrap/scss/mixins/_hover.scss","original":{"line":12,"column":-19},"name":null}
at SourceMapGenerator_validateMapping [as _validateMapping] (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\source-map\lib\source-map-generator.js:298:13)
at SourceMapGenerator_addMapping [as addMapping] (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\source-map\lib\source-map-generator.js:110:12)
at C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\concat-with-sourcemaps\index.js:60:28
at Array.forEach ()
at BasicSourceMapConsumer.SourceMapConsumer_eachMapping [as eachMapping] (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\source-map\lib\source-map-consumer.js:157:14)
at Concat.add (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\concat-with-sourcemaps\index.js:58:18)
at DestroyableTransform.bufferContents [as _transform] (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\gulp-concat\index.js:68:12)
at DestroyableTransform.Transform._read (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\readable-stream\lib\_stream_transform.js:182:10)
at DestroyableTransform.Transform._write (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\readable-stream\lib\_stream_transform.js:170:83)
at doWrite (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\readable-stream\lib\_stream_writable.js:406:64)
Node version - 8.9.4
npm version - 5.6.0
source-map version - 0.6.1