Deno doesn't have a way to install repositories from GitHub to the local node_modules folder.
Created
December 31, 2023 13:18
-
-
Save guest271314/c65965017b4e394cb7f40c7044e41f60 to your computer and use it in GitHub Desktop.
Install repositories from GitHub to node_modules for Deno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creates node_modules folder in pwd | |
// import "npm:esbuild"; | |
// import ... | |
const decoder = new TextDecoder(); | |
// Download GitHub repository to node_modules/.deno, link in node_modules | |
async function installRepositoryFromGitHubToNodeModules(url) { | |
return new Deno.Command("/bin/bash", { | |
/* | |
cd node_modules/.deno | |
git clone "$1" | |
cd .. | |
ln -s "`pwd`/.deno/$2" "`pwd`" | |
*/ | |
args: [ | |
"install_from_github.sh", | |
url, | |
url.split("/").pop(), | |
], | |
}).output(); | |
} | |
const { code, stdout, stderr } = await installRepositoryFromGitHubToNodeModules( | |
"https://github.com/guest271314/wbn-sign-webcrypto", | |
); | |
console.log([stdout, stderr].map((result) => decoder.decode(result))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd node_modules/.deno # Assumes node_modules folder exists in pwd | |
git clone "$1" | |
cd .. | |
ln -s "`pwd`/.deno/$2" "`pwd`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I did not follow how Deno does that for
import "npm:..."
completely. I omitted creating a nestednode_modules
folder innode_modules/.deno/<module_name>/node_modules/<actual_module>
. The code just createsnode_modules/.deno/<actual_module>
and links to that.