I'm trying to use your relaxed-json in my Electron app. Here is a simple code, GetDeviceList() is triggered on a button-push action:
const driver = require('meteor_driver').MeteorConnection.MeteorConnection;
const relaxed = require('relaxed-json');
const connection = new driver();
function GetDeviceList() {
console.log(connection.port);
console.log("Launching");
console.log(relaxed);
relaxed.transform('[{id:0,},{id:1,},{id:2,},]');
}
The console.log show me an empty object. And I got an error message Uncaught TypeError: relaxed.transform is not a function.
Otherwise, the package works properly when it's not used with electron.
Note that I don't encounter any require-related issue, so the modules must be valid isn't ?
Related
I was trying to make a sequence classifier using tf.js as a project. I trained a tensorflow.keras model on the data and converted the model to tfjs as below:
tfjs.converters.save_keras_model(model, './')
Then, I uploaded it into my javascript using the following code:
import * as tf from '#tensorflow/tfjs';
var model = null;
async function loadModel() {
model = await tf.loadLayersModel('assets/model/model.json');
console.log('Loaded')
}
loadModel();
I developed a function to make predictions. Code for the same is:
async function pred() {
tens = tf.zeros([batchSize, sentenceLength]);
const preds = await model.predict(tens);
return preds;
}
When I call pred() function it raises the following error:
TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
I can tell that the error happened in model.predict() line, but I am not able to debug this. Any help is appreciated.
Edit:
It seems that the cause of the error was the following tag in index.html file:
<script src="https://cdn.jsdelivr.net/npm/#tensorflow/tfjs#2.0.0/dist/tf.min.js"></script>
When I removed this line, the error got resolved.
I recently upgraded to Expo SDK 43.
I am now getting this error:
The line of code throwing it is:
if (!RCTAsyncStorage.multiMerge) {
I am on the latest version of AsyncStorage.
This seems to be due to my usage of firebase-js-sdk.
Unfortunately as this is an iOS/Android/Web project, it's necessary.
When I mock my Firebase exports, everything works:
const auth = () => {};
const analytics = () => {};
export default { auth, analytics };
But when I use the firebase-js-sdk functions, I get the above message.
This code causes an error (whichever version of auth I use)
let auth = initializeAuth(config, {
persistence: getReactNativePersistence(AsyncStorage),
});
//let auth = getAuth(config);
let analytics = getAnalytics(config);
export default { auth, analytics };
You could avoid that specific error by adding optional chaining (the question mark '?'):
if (!RCTAsyncStorage?.multiMerge) {
It will shortcircuit to undefined (thus making the if false) instead of throwing error from trying to check in the null object.
As to why RCTAsyncStorage would be null, you would have to check where you first get/declare it, and traceback to the point it didn't load, maybe you are using something conflicting from firebase-js-sdk.
Also multiMerge might not be supported always as mentioned in the docs:
multiMerge
[...] NOTE: This is not supported by all native implementations.
I created a react-app which I deployed online with npm run build, now everything locally works fine but when I try to load a page on my app it gives a error in Container.js ( no idea what this file is and what it does )
i've tried to reinstall all the node_modules without any result so I cloned my repo fresh but still without any result
Container.js:
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _reactRedux = require('react-redux');
var _Container = require('../components/Container');
var _Container2 = _interopRequireDefault(_Container);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
/**
* src/containers/Container.jsx
*/
var mapStateToProps = function mapStateToProps(store, ownProps) {
return {
items: store[ownProps.reduxStoreName].content[ownProps.reduxUid].filter(function (item) {
return item.parentId === ownProps.itemId;
})
};
};
exports.default = (0, _reactRedux.connect)(mapStateToProps)(_Container2.default);
Error in console: Uncaught (in promise) TypeError: Cannot read property 'filter' of undefined
well, like #Pointy mentioned in his comment, it basically means that store[ownProps.reduxStoreName].content[ownProps.reduxUid] is undefined.
It is not the file which is causing the error, its the specific line. When the code reaches this line and tries to execute it- that store[ownProps.reduxStoreName].content[ownProps.reduxUid] parameter is undefined so it crushes.
We cannot tell you where the error is, we'd need the code of your whole app to follow the execution flow.
You have to follow it yourself, and understand why there is not an array in that variable when the code gets there.
As a general idea, try figure out the following:
when and where that variable is initialized?
when and where do you call mapStateToProps?
are you absolutely sure that the code which answers question 1 is executed before the code which answers to question 2? (maybe there is an asynchronous execution problem you didn't think about which causes your code to execute at the wrong order)
if it does- maybe the way you initialize those variables at the beggining is not correct? maybe you use a 3rd party library / function to initialize them, but not actually getting the result you expecting? or maybe you're using it wrong, or parsing the result wrong?
I'm using remark-math to render maths equations from Markdown. This has previously been working without a hitch, however after I refactored some seemingly unrelated code, I now get the following exception:
Uncaught ReferenceError: INLINE_MATH_DOUBLE is not defined
at Of.inlineTokenizer (inline.js:12)
at Of.tokenize [as tokenizeInline] (tokenizer.js:111)
at Of.atxHeading (heading-atx.js:148)
at Of.tokenize [as tokenizeBlock] (tokenizer.js:111)
at Of.parse (parse.js:41)
at Function.parse (index.js:275)
at pipelineParse (index.js:22)
at wrapped (index.js:93)
at next (index.js:56)
at Object.run (index.js:30)
The relevant code from ./node_modules/remark-math/inline.js looks like the following:
const ESCAPED_INLINE_MATH = /^\\\$/
const INLINE_MATH = /^\$((?:\\\$|[^$])+)\$/
const INLINE_MATH_DOUBLE = /^\$\$((?:\\\$|[^$])+)\$\$/ // << defined here?
module.exports = function inlinePlugin (opts) {
function inlineTokenizer (eat, value, silent) {
let isDouble = true
let match = INLINE_MATH_DOUBLE.exec(value) // << line 12, error here
// ...remaining code
The constant appears to be defined in scope!
I'm building using webpack and the chentsulin/electron-react-boilerplate template. Any hints as to why this kind of exception would suddenly be happening? (I've tried a complete reinstall of node_modules.)
maybe some issues happen from webpack building.
if the error still happen, and you want to avoid it, you can use this
GLOBAL.INLINE_MATH_DOUBLE = /^\$\$((?:\\\$|[^$])+)\$\$/
I reinstalled the dependencies with yarn instead of npm and the issue went away.
Facebook authentication works great, but when I go to make a Graph request:
const infoRequest = new GraphRequest(
'/me',
{
accessToken: tokenString,
fields: 'email,first_name,name,last_name,picture'
},
this._responseInfoCallback
);
new GraphRequestManager().addRequest(infoRequest).start();
}
I get "TypeError: Cannot read property 'start' of undefined"
Using the Chrome debugger, everything appears like it should be working, and even storing GraphRequestManager as a variable has everything it needs until I call start(). Even using sample code I've found on this site fails when I call start(). Am I missing something obvious?
Here's a little more info. I'm importing with this:
const FBSDK = require('react-native-fbsdk');
const {
GraphRequest,
GraphRequestManager
} = FBSDK;
If I use FBGraphRequest and FBGraphRequestManager instead of above, I get errors stating that GraphReqest, etc aren't functions when I use them. Otherwise, the rest of my code looks very similar to Shivam's, but I get 'Cannot read property 'start' of undefined', so obviously the GraphRequestManager call is failing or isn't defined (which makes no sense to me).
In my experience, the fields you wish to request are specified inside parameters:
AccessToken.getCurrentAccessToken().then(
(data) => {
let accessToken = data.accessToken
const infoRequest = new GraphRequest(
'/me',{
accessToken: accessToken.toString(),
parameters: {
fields: {
string: 'email,first_name,name,last_name,picture'
}
}
},
this._responseInfoCallback.bind(this),
);
new GraphRequestManager().addRequest(infoRequest).start();
})
Ps where did you place the functions? Are they inside the class?