Back to Tutorials
Node.js
12 min read
Sahasransu Satpathy
9/1/2025
npm install not working? Solutions
Common npm install errors and how to fix them step by step.
<h2>Introduction</h2>
<p><code>npm install</code> is one of the most used commands in Node.js projects. But sometimes, it throws errors like <em>permission denied</em>, <em>missing package.json</em>, or <em>network issues</em>. In this guide, we’ll cover the most common problems and their fixes.</p>
<h3>1. npm command not found</h3>
<p>This means Node.js or npm is not installed correctly.</p>
<pre><code># Install Node.js (includes npm)
https://nodejs.org/</code></pre>
<h3>2. Permission Errors (EACCES)</h3>
<p>Occurs when npm doesn’t have permission to write to global folders.</p>
<pre><code># Fix using nvm (recommended)
nvm install node nvm use node</code></pre> <p>Or run with <code>sudo</code> (not recommended).</p>
<h3>3. package.json Missing</h3>
<p><code>npm install</code> requires a <code>package.json</code> file.</p>
<pre><code>npm init -y</code></pre>
<h3>4. Internet / Proxy Issues</h3>
<p>Sometimes npm can’t connect to registry.</p>
<pre><code>npm config set registry https://registry.npmjs.org/</code></pre>
<h3>5. Clear npm Cache</h3>
<p>Corrupted cache can block installation.</p>
<pre><code>npm cache clean --force</code></pre>
<h3>6. Delete node_modules & package-lock.json</h3>
<p>If dependencies break:</p>
<pre><code>rm -rf node_modules package-lock.json
npm install</code></pre>
<h3>7. Use Legacy Peer Deps</h3>
<p>For dependency conflicts in React/Angular projects:</p>
<pre><code>npm install --legacy-peer-deps</code></pre>
<h3>8. Outdated npm Version</h3>
<pre><code>npm install -g npm@latest</code></pre>
<h3>9. Firewall / Antivirus Blocking</h3>
<p>Whitelist npm in firewall or try using mobile hotspot temporarily.</p>
<h3>10. Yarn / pnpm Alternative</h3>
<p>If npm still fails, try:</p>
<pre><code>yarn install
pnpm install</code></pre>
<h3>Conclusion</h3>
<p>Most <code>npm install</code> issues come from permission, cache, or dependency conflicts. Start by cleaning cache and reinstalling dependencies. If nothing works, reinstall Node.js and npm fresh.</p>
Previous Tutorial
Browse All TutorialsNext Tutorial
Browse All Tutorials