This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
5. Using NPM Packages
Sammy edited this page Aug 23, 2022
·
2 revisions
If you want to use NPM Packages in your plugin, you have 3 Options here
1 - You can push the NPM packages to your Plugin Repository; this has the advantage that the Plugin works right out of the box, however it can cause issues sometimes and increases download time.
2 - (Recommended) You can use a script in your plugin to Install NPM Packages at Runtime; This has the advantage that the size of your Plugin stays small and your Repository looks cleaner. An example script for that would look like this
//Top of index.js
const { existsSync } = require("fs");
const { exec } = require("child_process");
const nodeModulesPath = join(__dirname,"node_modules");
async function installDeps() {
return new Promise((res) => {
exec("npm install", { cwd: __dirname }, (err, stdout, stderr) => {
if (err) {
res();
}
res();
})
})
}
if (!existsSync(nodeModulesPath)) {
installDeps().then(() => {
setTimeout(() => {
powercord.pluginManager.remount(__dirname);
}, 1000)
})
}
//Actual start of the plugin
[...]
3 - Tell users to Manuallly run "npm i" inside the plugins Folder.