View Node-version-managers.md
Node Version Managers
I tried nvm many years ago and it had several issues that I remember:
- Setup was not as simple compared to n at the time
- It was quite slow moving from one Node version to another
- Couldn't automatically switch the Node version when entering a folder (now they cover that)
- In the past I used avn for that, but it was slow as well
- Global packages were lost when moving from one Node version to another
- Tbh, fnm has the same issue now, hopefully they'll add support for it soon
View Why-not-index-files.md
Why not index files
Using
index.{jsx,tsx}
for Components orindex.{js,ts}
for other files
- Hard to search for a component or file based on it’s name (the
index
file is only on the 7th result)
- Opening several
index
files in the IDE results in hard to read tabs with needlessindex
keywords
View Default vs Named Exports.md
Default vs. Named Exports
Named Exports Benefits
- Find Usages/Find References - Easier to search for the export across the project. Less likely to have been renamed or misspelled
- Easier refactoring of the exported name
- No need to think of a variable name. Sometimes it's unclear from the file name, especially if it's
../index.js
- Choosing a named export with IntelliSense autocomplete is faster than writing your own variable. Also prevents spelling mistakes
- If we only had named exports, it would be easier for new developers to learn how to use it, as there is no extra logical step of choosing which type of import or export to use
View Importing Modules Setup.md
Import Aliases
In an effort to keep import
statements clean and easy to work with, we can use import aliases.
For example (anywhere in the app
or src
tree):
import { network } from 'lib/network';
import { colors } from 'styles/theme';
import useThrottledEvent from 'hooks/useThrottledEvent';
View StackBlitz.md
StackBlitz - Introducing WebContainers: Run Node.js natively in your browser
Good Things
- Really easy to start up a new project and play around with it locally (like in CodeSandbox, but supports Node.js as well).
- Turns out CodeSandbox have an experimental support for Node.js projects as well 😳 I don't know if they run it locally or remotely, and you can't
clone
and existing Node repo and run it.
- Turns out CodeSandbox have an experimental support for Node.js projects as well 😳 I don't know if they run it locally or remotely, and you can't
- Can connect to any repo on GitHub and play around with the code (if the Node.js version matches):
- If it's my repo, I can directly
commit
to it. That's actually nice, cause it could be a very fast workflow for quick changes.
- If it's my repo, I can directly
- Can run on a Tablet or Chromebook.
View env-configs.md
.env vs. node-config
.env
Pros
- Very simple to setup.
- Automatically assigns configured values on top of
process.env
. - Automatically supports overriding configured values via Environment Variables.
- Promotes best practices (FAQ):
View Volta.md
Volta
A really nice tool to manage the different Node.js/npm/yarn versions between projects:
The problems it solves
- Making sure everyone who works on the project uses the same Node.js/npm/yarn version for consistent dependencies tree and Node.js execution.
- Switching the Node.js version when jumping between projects.
NewerOlder