Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Fernando B 🚀
Fernando B 🚀

Posted on

     

Save time and disk space for node projects

Do you like saving time, and precious disk space when working on npm projects? If the answer is yes, then this post is for you.

Recently I have been learning electron, and react-electron. One huge problem when setting up these types of projects is the overhead of setting up a few files, and then waiting for tons of package installs. If you don't believe try this templatehttps://github.com/electron-react-boilerplate/electron-react-boilerplate. Check your disk size prior tonpm install, and afterwards. Also time how long it takes.

  • Original size after git clone 4MB
  • yarn (30seconds, I had to install yarn, above repo is really picky about npm)
  • 635MB size after installing packages

PNPM for installing packages

If you don't know about pnpm, it has a global store, then when you dopnpm install lodash it creates a linked directory innode_modules, but the package is not re-downloaded thirty million times. Only once, and then later on when you want to update it.

https://pnpm.js.org/

That along will save you tons of space, but wait there is more.

Creating projects with a shell function

On my~/git directory, I have two templates I use quite often.

  • electron-app-template
  • cra-electron-template

You can make any project you'd like, set it up how you want it. Make sure it runs on dev, production, build, etc. When you are happy with your template, add a function to bash or in my case fish:

Fish create-electron-app.fish inside~/.config/fish/functions

function create-electron-app --argument dir    mkdir $dir    cp -RT ~/git/electron-template $dirend
Enter fullscreen modeExit fullscreen mode

From the command line I can run the following to create a new project in a split second:

$ create-electron-app fab-project
Enter fullscreen modeExit fullscreen mode

Bash (Create this function whatever you put your functions):

create-electron-app(){    mkdir $1    cp -RT ~/git/electron-template $1}
Enter fullscreen modeExit fullscreen mode

I hope you enjoyed this post, and let me know what other saving time, and disk space you have in your repertoire. Thanks for reading!

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
thefern profile image
Fernando B 🚀
Coding space junkie with a sprinkle of writer heart. DMs open for any questions or comments. 🙂
  • Location
    Houston, TX
  • Work
    Software Engineer at The Fern
  • Joined

You're welcome, to be honest I didn't know until pnpm until recently.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Coding space junkie with a sprinkle of writer heart. DMs open for any questions or comments. 🙂
  • Location
    Houston, TX
  • Work
    Software Engineer at The Fern
  • Joined

More fromFernando B 🚀

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp