You can't exactly run an npm command, because npm
is a package manager for node
, commands run in npm will be for package management, whereas commands run in node
itself is what you need to get the utilities functions.
I did a lot of research on this and found one solution. What you want to do is, after installing the package you want to check on using npm
, let's say it's discord.js
:
npm install discord.js
Now, run node directly, no index.js
or any other files required.
node
Then, use the following command:
Object.keys(require('discord.js'))
While in node, this will return a list of all it's utilities. Of course, this example was using discord.js
, though it can be any npm packages with utility functions.
This should return something like:
[
'BaseClient', 'Client', 'Shard',
'ShardClientUtil', 'ShardingManager', 'WebhookClient',
'ActivityFlags', 'BitField', 'Collection',
'Constants', 'DataResolver', 'BaseManager',
'DiscordAPIError', 'HTTPError', 'MessageFlags',
'Intents', 'Permissions', 'Speaking',
'Snowflake', 'SnowflakeUtil', 'Structures',
'SystemChannelFlags', 'UserFlags', 'Util',
'version', 'ChannelManager', 'GuildChannelManager',
'GuildEmojiManager', 'GuildEmojiRoleManager', 'GuildMemberManager',
'GuildMemberRoleManager', 'GuildManager', 'ReactionManager',
'ReactionUserManager', 'MessageManager', 'PresenceManager',
'RoleManager', 'UserManager', 'discordSort',
'escapeMarkdown', 'fetchRecommendedShards', 'resolveColor',
'resolveString', 'splitMessage', 'Base',
'Activity', 'APIMessage', 'BaseGuildEmoji',
'CategoryChannel', 'Channel', 'ClientApplication',
'ClientUser', 'Collector', 'DMChannel',
'Emoji', 'Guild', 'GuildAuditLogs',
'GuildChannel', 'GuildEmoji', 'GuildMember',
'GuildPreview', 'Integration', 'Invite',
'Message', 'MessageAttachment', 'MessageCollector',
'MessageEmbed', 'MessageMentions', 'MessageReaction',
'NewsChannel', 'PermissionOverwrites', 'Presence',
'ClientPresence', 'ReactionCollector', 'ReactionEmoji',
'RichPresenceAssets', 'Role', 'StoreChannel',
'Team', 'TeamMember', 'TextChannel',
'User', 'VoiceChannel', 'VoiceRegion',
'VoiceState', 'Webhook', 'WebSocket'
]
Which is basically all the utility functions available in discord.js
. Now, sometimes, you will run into this error:
SyntaxError: Cannot use import statement inside the Node.js REPL, alternatively use dynamic import
This is because I'm running it from node
and not from a module or app. Then if you try it inside a non-module package, like a bot in discord.js
, it will return this error:
SyntaxError: Cannot use import statement outside a module
These two errors above won't show up if you're making a module instead and calling import from inside the module.
This is because a discord.js
bot isn't a module and if I force define module in the package.json
, it will break. In this case, there's nothing you can do from inside, you can try to look up it's documentations or source code to find it yourself.
Here're some references to using this command:
Sadly, I don't know if there are any npm commands to do this with. – Mineko Kayui Sep 06 '20 at 04:52