Node.js, npm && version control with nvm

Node.js, npm && version control with nvm

Tags
Node.js
Setup
Published
January 13, 2024
Author
TOC

Installation

setup global path and cache path
npm config set prefix "D:\ProgramData\nodejs\node_global" npm config set cache "D:\ProgramData\nodejs\node_cache"
💡
What npm config set does is actually modifying the ~/.npmrc file
 
install a package globally, for instance, yarn
npm install --global yarn
 
Add D:\ProgramData\nodejs\node_global to the environmental variable
 
check installation
yarn --version
 

Node version control with nvm

nvm ls # list out all installed node versions nvm current # check current active node version nvm use 20 # activate version 20
nvm
nvm-shUpdated Oct 25, 2024

Packages

 

What is the @ in the package name?

what is the difference between npm package with and without@
When working with npm, the use of "@" in a package name signifies the package's scope, which is typically associated with a specific organization or user. For example, "@angular/core" is a scoped package for the Angular framework, and "express" is an unscoped package. When installing a package, the "@" is used to specify the scope of the package. For instance, to install a scoped package, you would use "npm install @scope/package-name," and for an unscoped package, you would use "npm install package-name"[1]. If you want to install a package without setting up a package.json file, you can run "npm install <package-name>" in your project's directory. However, it's important to note that this approach is not recommended for production projects, as the package.json file is essential for managing dependencies and defining the project's configuration[2]. Additionally, when creating an npm package, it's important to follow modern best practices to ensure its security and readiness for production environments. This involves setting up the package with proper testing, security checks, and support for modern module formats such as CommonJS (CJS) and ECMAScript (ESM) [3]. In summary, the "@" in an npm package name indicates its scope, and it's important to use the package.json file to manage dependencies and project configuration effectively. When creating an npm package, following best practices will help ensure its security and readiness for production use.
what is the difference between npm package with and without@
 
 

pnpm

pnpm
pnpmUpdated Oct 25, 2024