"Uncaught Error: Cannot find module 'url"' by using matrix-js-sdk - javascript

The error is:
Uncaught Error: Cannot find module 'url'
I my only code is:
import sdk from 'matrix-js-sdk';
const client = sdk.createClient("https://matrix.org");
client.login("m.login.password", {"user": "Jak2k", "password": localStorage.getItem("pass")}).then((response) => {
console.log(response.access_token);
});
Before that, I just installed it with npm.(Maybe it's important, that I use react in the same package.)

Related

error: A hook (`userconfig`) failed to load and module export

info: Winston logger has been started on Ridepal
error: A hook (userconfig) failed to load!
error: Failed to lift app: Error: When using aggregate, modules must export dictionaries. But module (scala\route-matcher) is invalid:function matchesRoute(testRoute) { console.log("testRoute", testRoute); return routes.some((route) => route.match(testRoute)); }enter image description here

uncaught promise rejection: failed to eval source for module 'nanoid': node_modules/nanoid/index.cjs

I'm trying to use nanoid (https://www.npmjs.com/package/nanoid/v/2.1.2)
exports = async function(){
const nanoid = require("nanoid");
const uid = nanoid(10);
}
From within MongoDB realm runtime, but it throws:
uncaught promise rejection: failed to eval source for module 'nanoid': node_modules/nanoid/index.cjs: Line 9:7 Unexpected identifier (and 16 more errors)
And this is about all the error I can see from the Realm Dashboard.
What could be missing?
The solution that worked for me:
Install a lower version nanoid
npm i nanoid#2.1.2
Then upload the package to MongoDB Realm functions through the dashboard.

Angular 8 - Getting Runtime compiler not loaded error

I need to dynamically create lazy loaded routes. When I use import syntax, e.g. loadChildren: () => import(`./pages/${module.moduleName}/${module.moduleName}.module`).then(m => m[childModuleName]), it works on JIT but when running on AOT, it throws this error:
ERROR Error: Uncaught (in promise): Error: Runtime compiler is not loaded as per https://github.com/angular/angular-cli/issues/10582 the solution would be to use the old string syntax:
```` loadChildren: ./pages/${module.moduleName/${module.moduleName}.module#${childModuleName},
I get this error:
``` ERROR Error: Uncaught (in promise): Error: Cannot find module './pages/client-migration/client-migration.module.ngfactory' ```
import the module name into your module.ts.

Load JSON file using node require and absolute path fails

I'm trying to require a JSON file using require. But it fails miserably though the file does exist. I'm wondering if it's because I try to load a JSON file instead of a JS file there, as I usually do.
error: verbose: Evaluating c:\wamp\www\Ayolan\Translation\config/locales/languages.json as module "c:\wamp\www\Ayolan\Translation\config/locales/languages.json" failed with error: SyntaxError: Unexpected token :
It seems that it doesn't like the : character in the windows path. What solution do I have here? I cannot use a relative path to the file because it's a shared file that is loading a file that depends on the application config.
var pathLanguages = __config.path.base + __config.path.languages;
var languages = require(pathLanguages + 'languages.json');
I believe loading JS file using this method would work. (I've just made the test and it does work with JS file)
Using node 0.10.24
JSON file:
{
"fr": {
"min": "fr",
"lang": "fr-fr",
"language": "Français"
},
"en": {
"min": "en",
"lang": "en-en",
"language": "English"
}
}
Error message:
error: Error: Evaluating c:\wamp\www\Ayolan\Translation\config/locales/fr.json as module "c:\wamp\www\Ayolan\Translation\config/locales/fr.json" failed with error: SyntaxError: Unexpected token :
at Function.req.load (c:\wamp\www\Ayolan\Translation\node_modules\requirejs\bin\r.js:2505:23)
at Function.req.get (c:\wamp\www\Ayolan\Translation\node_modules\requirejs\bin\r.js:2455:29)
at localRequire (c:\wamp\www\Ayolan\Translation\node_modules\requirejs\bin\r.js:1632:40)
at c:\wamp\www\Ayolan\Translation\shared\app\Lang.js:36:48
at forOwn (c:\wamp\www\Ayolan\Translation\node_modules\lodash\dist\lodash.js:2105:15)
at Function.forEach (c:\wamp\www\Ayolan\Translation\node_modules\lodash\dist\lodash.js:3302:9)
at Function.Lang._loadAllLanguages (c:\wamp\www\Ayolan\Translation\shared\app\Lang.js:34:15)
at Object.module.exports.bootstrap (c:\wamp\www\Ayolan\Translation\config\bootstrap.js:28:12)
at Sails.runBootstrap (c:\wamp\www\Ayolan\Translation\node_modules\sails\lib\app\private\bootstrap.js:46:27)
at Sails.bound [as runBootstrap] (c:\wamp\www\Ayolan\Translation\node_modules\lodash\dist\lodash.js:729:21) { [Error: Evaluating c:\wamp\www\Ayolan\Translation\config/locales/fr.json as module "c:\wamp\www\Ayolan\Translation\config/locales/fr.json" failed with error: SyntaxError: Unexpected token :]
originalError: [SyntaxError: Unexpected token :],
moduleName: 'c:\\wamp\\www\\Ayolan\\Translation\\config/locales/fr.json',
requireModules: [ 'c:\\wamp\\www\\Ayolan\\Translation\\config/locales/fr.json' ],
fileName: 'c:\\wamp\\www\\Ayolan\\Translation\\config/locales/fr.json' }

How can I install the standalone ember router?

I'm having trouble installing this -> https://github.com/tildeio/router.js in my MVC project.
I first just loaded these two scripts:
vendor/deps/route-recognizer.js
dist/router.js
Added the line:
var router = new Router();
I ended up with the following console errors:
Uncaught ReferenceError: define is not defined ***route-recognizer.js:1***
Uncaught TypeError: Cannot read property 'Promise' of undefined ***router.js:2084***
Uncaught ReferenceError: Router is not defined
I then loaded these scripts:
vendor/loader.js
vendor/deps/backburner.js
vendor/deps/rsvp.js
vendor/deps/route-recognizer.js
dist/router.js
I get these errors:
Uncaught TypeError: Cannot read property 'Promise' of undefined ***router.js:2084***
Uncaught ReferenceError: Router is not defined
This is code where the 'Promise' error occurs:
define("route-recognizer", [], function() { return {"default": RouteRecognizer}; });
define("rsvp", [], function() { return RSVP;});
-->define("rsvp/promise", [], function() { return {"default": RSVP.Promise}; });
Is there a promise.js I need as well? I found a promise.js in the RSVP.js package but loading gives me another error.
Was having the same problem.
There seem to be a code change according to this post for router.js to work as a standalone.
Grab the laters rsvp, route-recognizer and router and create a router object like so
<script src="routerjs/rsvp-latest.js"></script>
<script src="routerjs/route-recognizer.js"></script>
<script src="routerjs/router.min.js"></script>
<script>
var router = new Router["default"]();
</script>

Categories