npm
npm is a package manager for the JavaScript programming language. It consists of a command line client, and an online database of public and paid-for private packages, called the npm registry.

Perintah Umum

Buat app baru

Nodejs

1
npx gitignore node
2
npm init -y
Copied!

Nextjs

1
npm init next-app <project_name>
Copied!

Install dependencies

Jalankan perintah berikut dalam folder app yang sedang aktif.
1
npm i <package_name>
Copied!

Cek outdated package

Outdated global
1
npm outdated -g
Copied!
Outdated local
1
npm outdated
Copied!

Update package

Update global
1
npm update -g <package_name>
Copied!
Update local
1
npm update <package_name>
Copied!

Build package

Jalankan perintah berikut dalam folder project.
1
npm run build
Copied!

Semantic Versioning

1
npm version major
Copied!
1
npm version minor
Copied!
1
npm version patch
Copied!

Publish npm packages

1
npm login
2
npm publish
Copied!

Troubleshooting

Cara mudah update npm di Windows lewat PowerShell

  1. 1.
    Buka PowerShell dengan opsi Run as Administrator
  2. 2.
    Ketik Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
  3. 3.
    Install package npm-windows-upgrade dengan command,
    1
    npm install --global --production npm-windows-upgrade
    2
    npm-windows-upgrade
    Copied!
  4. 4.
    Jika ingin langsung mengupgrade, jalankan perintah ini.
    1
    npm-windows-upgrade --npm-version latest
    Copied!
Referensi:
GitHub - felixrieseberg/npm-windows-upgrade: Upgrade npm on Windows
GitHub
โ€‹
Last modified 1yr ago