Get the IP address to check a localhost webpage on the phone when the server is running on the Mac. Don't forget to add the port. (e.g. 192.168.1.34:3000). Note that this works only when both the Mac and your phone are on the same network.
Node Version Manager is super useful for switching between node.js versions.
nvm ls
nvm use stable
nvm use v14.19.2
nvm alias default 16.13.2
npm
Install a specific npm version
When using node.js version, a version of npm that ships with that node version will be used by default.
To override, you can specifically install the version of npm you like (of course, you should be aware of the compatibility between those node and npm versions). To achieve this, install a specific npm version like so:
npm install -g npm@8.10.0
Note: When using nvm, if you switch node versions, the paired version of npm will be used.
Explanation: node v14.19.2 ships with npm v6.14.17 and node v16.13.2 came with npm v8.1.2 ; now, if you install a different npm version by using the command above, say for node v14.19.2 you installed npm v8.10.0 ; And now you decided to switch to node v16.13.2 ; When you switch to node v16.13.2 and check npm -v you'll see 8.1.2. So each npm package install instance (?) is tied to a specific node version when using nvm.
More npm commands
[ ] Todo explain, or at least add a title each.
npm i --legacy-peer-deps
npm i -g sails
npm link local-package
summary: Oft-used useful code snippets I like keeping handy url: https://shreshth.dev/blog/snippets
Open a page on mobile when on localhost (Mac)
Get the IP address to check a localhost webpage on the phone when the server is running on the Mac. Don't forget to add the port. (e.g.
192.168.1.34:3000
). Note that this works only when both the Mac and your phone are on the same network.Some servers might not expose this over the network. For instance with astro you need to add
--host
to expose the app running over the networkSide note:
navigator.clipboard.writeText()
won't work on iOS Safari for security reasons (TODO: ref)Anchor element which opens a link in a new tab, safely.
target="_blank"
attribute-value pairBrew
Start a service installed via brew.
Optionally use
--verbose
to debug any issuesStop a service installed via brew.
See which services are running via brew
List packages installed via brew
Misc brew commands
NVM
Node Version Manager is super useful for switching between node.js versions.
npm
Install a specific npm version
When using node.js version, a version of npm that ships with that node version will be used by default. To override, you can specifically install the version of npm you like (of course, you should be aware of the compatibility between those node and npm versions). To achieve this, install a specific npm version like so:
Note: When using nvm, if you switch node versions, the paired version of npm will be used. Explanation: node v14.19.2 ships with npm v6.14.17 and node v16.13.2 came with npm v8.1.2 ; now, if you install a different npm version by using the command above, say for node v14.19.2 you installed npm v8.10.0 ; And now you decided to switch to node v16.13.2 ; When you switch to node v16.13.2 and check
npm -v
you'll see8.1.2
. So each npm package install instance (?) is tied to a specific node version when using nvm.More npm commands