package.json global code example Example 1: install npm globally npm install npm@latest -g Example 2: install npm package globally npm install package-name -g