I've been trying to debug this for the last hour or so to no avail. I'm attempting to use d3-world-maps, which has a dependency on topojson.
Inside the d3-world-maps package lies the issue:
var _topojson = require('topojson');
var _topojson2 = _interopRequireDefault(_topojson);
this.countries = _topojson['default'].feature(_assetsTopo_countriesJson2['default'], _assetsTopo_countriesJson2['default'].objects.countries);
It seems that _topojson['default'] is undefined, and I'm not quite familiar with this library or its dependencies enough to figure out why...
Would anyone be able to point me in the right direction? I've logged the object and I can see that the property default is undefined (the object exists) - however I'm not sure why d3-world-maps uses it if it doesn't exist... unless I've missed something here.
Edit:
Just looked at the function:
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { 'default': obj };
}
What exactly is this doing and why?
The issue appears to be an API change in topojson. As you can see here, d3-world-maps uses * for the topojson version, which means that it will just keep getting the latest version no matter what.
Try editing the package to use a specific, older version of topojson and find the version that it's expecting and submit a pull request to the package to fix it!
Related
There’s this error i get after i try to login to discord using my bot’s dashboard:
> TypeError: Discord.Permissions is not a constructor
Code:
const _perms = guild.permissions_new;
const _checkBot = client.guilds.cache.get(guild.id);
_guilds[index].bot_added = _checkBot ? true : false;
_guilds[index].permissions = new Discord.Permissions(_perms).toArray();
});
delete _user.accessToken;
_user.permissions = _dbUser ? _dbUser.permissions : [];
_user.notifications = _dbUser ? _dbUser.notifications : [];
_user.connections = {};
_user.guilds = _guilds;
Any help would be appreciated. 🙏
I tried to log in my discord bot’s website dashboard via discord connection, while expecting it to work, it just opened up a discord authorization page that doesn’t let you do anything while being refreshed in loop
When in doubt, check the documentation.
Permissions isn't there. Therefore, one shouldn't expect this to work. There is PermissionsBitField, however, and running console.log(new PermissionsBitField(8n).toArray()); returns ["Administrator"]. This is likely what you are looking for.
I searched this specific piece of code in GitHub and found 3 results of which all seem to be the same copy of code and which all appear to be using discord.js 13.x. What very likely happened here is you installed discord.js 14.x (as such is the current latest stable version) and ran version 13 code on it. Unfortunately, this will not work (as evident). There is an update guide you should browse through.
I have been trying to implement pg-postgis-types npm package in my express project for my internship. I'm using PostgreSQL and Sequelize.
Unfortunately, although I have implemented the code in the documentation, our API returns pgtypes.fetcher is not a function. Does anyone encounter with this issue? I checked the definition of the package in node modules folder and I found the definition, as it should be.
To be a reference, my code is like below.
const getgeojson = async (mapID) => {
try {
postgis(pgtypes.fetcher(pg, connection), null, (err, oids) => {
if (err) {
throw err;
}; ...
I know this is not a much popular repo but maybe someone encounter and solved it before, I just wanted to ask. Sorry if this is a bad question :)
The package is much older, thus, the usage is slightly different from the original documentation in both npm and GitHub repo. You can call functions by changing postgisto postgis.default and pgtypes.fetcher to pgtypes.default.fetcher. This solved my stated issue above. Have a nice day y'all.
I haven't used my Discord recently but the last time I ran it, it still worked perfectly. However, I keep getting this error Cannot set property 'avatar' of undefined at Member.set [as avatar] these days.
Can someone help me?
I was struggling with this issue and eventually figured it out. It's because the 'this' keyword is getting hijacked somehow in the code within the Object.defineProperty call inside the Member constructor(line 2606 in my version of index.js, but I've made a few other fixes already so yours is probably different). I was able to fix it by caching off the 'this' reference into a private member and referencing that instead. It feels hacky but it works. Like so:
function Member(client, server, data) {
copyKeys(data, this, ['user', 'joined_at',]);
this.id = data.user.id;
this.joined_at = Date.parse(data.joined_at);
this.color = colorFromRole(server, this);
var tempThis = this;
['username', 'discriminator', 'bot', 'avatar', 'game'].forEach(function(k) {
if (k in Member.prototype) return;
Object.defineProperty(Member.prototype, k, {
get: function() { return client.users[tempThis.id][k]; },
set: function(v) { client.users[tempThis.id][k] = v; },
enumerable: true,
});
});
}
I just experienced the same error with my own bot completely out of the blue. After some investigation, I checked the code at DiscordClient.handleWSMessage (on my error it was showing at index.js:1871:31 as opposed to index.js:1891:31, however I'm not sure if it's a matter of having different versions of discord.io installed) - in any case, the error seemed to be stemming from the Event switch statement responding to a GUILD_CREATE event - this may be different for you:
case "GUILD_CREATE":
/*The lib will attempt to create the server using the response from the
REST API, if the user using the lib creates the server. There are missing keys, however.
So we still need this GUILD_CREATE event to fill in the blanks.
If It's not our created server, then there will be no server with that ID in the cache,
So go ahead and create one.*/
client.servers[_data.id] = new Server(client, _data);
return emit(client, message, client.servers[_data.id]);
I don't understand why GUILD_CREATE events are being received, my bot has never been programmed to handle these, however commenting out the executable lines in the switch case above and replacing them with an empty return statement seemed to stop the error occurring, and my bot stayed connected (so far, I've only been testing for a few minutes).
Might not work for everyone, but on my computer this issue was resolved by saving and only running after I saved. Slightly annoying but it worked!
I'm giving a try with [react-native-crypto][1] in order to learn how to convert nodejs to be used in React Native project in the future. Unfortunately, I couldn't get it running successfully. I've faced an issue with stream is undefined. ERROR TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[0], "stream").Transform.call').
If you have ever faced a similar problem, I'm so grateful for your help.
Also, I attach the screenshot of the issue as the following
For anyone still trying to solve this issue, I have figured out a solution that worked for me. So within node_modules/cipher-base/index.js, the top of the file should have a line which defines the variable Transform as var Transform = require('stream').Transform. For some reason, it does not like the module stream and as such it needs to be changed to readable-stream. Therefore the variable Transform should now read var Transform = require('readable-stream').Transform.
From what I have gathered, the stream module it is trying to refer to isnt actually a module that can be used. The reason why it gets referenced however seems to be because the tsconfig.json file in the root directory specifies "stream": ["./node_modules/readable-stream"] as a path, almost as if to make stream refer to the readable-stream module, which in theory it should refer to when it is called. But in this case it doesnt happen so we need to explicitly define that we are refering to the readable-stream module.
Hope this helps anyone else out there and prevents others scratching their heads for hours on end like it did for me!
I have figured it out by editing in metro.config.js as the following:
resolver: {
extraNodeModules: {
stream: require.resolve('stream-browserify'),
}
},
Getting that error in my javascript console(in Chrome) with a collada object I'm attempting to add with a basic loader. It's specifically coming from the "scene.add( object )" chunk of it. Everything else seems to work just fine. The code for loading the object is as follows
var ltable;
var furnLoad = new THREE.ColladaLoader();
function addlt(){
furnLoad.load('../Models/Furniture/foldingLongTable.dae', function(collada){
ltable = collada.scene;
ltable.scale.x=ltable.scale.y=ltable.scale.z=1;
ltable.updateMatrix();
ltable.position.x=ltable.position.z=ltable.position.y=0;
});
scene.add( ltable );
}
This function is called during the init of a page that, otherwise, works just fine. That page can be found here(version without this table has the same URL except for a 4 instead of a 3 at the end), and the specific object here.
What would be the recommended way to get past this error?
RESOLVED. Collada loaders just hate being part of any function and won't work when in them. So the fix is to have them outside of functions and they work just fine.
The answer to this issue is due to the location of the scene.add() being outside of the callback function. It is being called before the callback fires, hence the undefined error.