npm install -g netlify-clinpm error code EACCESnpm error syscall mkdirnpm error path /usr/lib/node_modules/netlify-clinpm error errno -13npm error Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/netlify-cli'npm error at async mkdir (node:internal/fs/promises:859:10)npm error at async /usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:639:20npm error at async Promise.allSettled (index 0)npm error at async [reifyPackages] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:337:11)npm error at async Arborist.reify (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:142:5)npm error at async Install.exec (/usr/lib/node_modules/npm/lib/commands/install.js:149:5)npm error at async Npm.exec (/usr/lib/node_modules/npm/lib/npm.js:208:9)npm error at async module.exports (/usr/lib/node_modules/npm/lib/cli/entry.js:67:5) {npm error errno: -13,npm error code: 'EACCES',npm error syscall: 'mkdir',npm error path: '/usr/lib/node_modules/netlify-cli'npm error }npm errornpm error The operation was rejected by your operating system.npm error It is likely you do not have the permissions to access this file as the current usernpm errornpm error If you believe this might be a permissions issue, please double-check thenpm error permissions of the file and its containing directories, or try runningnpm error the command again as root/Administrator.npm error A complete log of this run can be found in: /home/prtk/.npm/_logs/2025-07-07T09_26_30_080Z-debug-0.log
This is a permissions issue. Let's fix it and deploy to Netlify using alternative methods.
sudo npm install -g netlify-cli# Create a directory for global packages
mkdir ~/.npm-global
# Configure npm to use the new directory
npm config set prefix '~/.npm-global'
# Add to your shell profile (.bashrc, .zshrc, etc.)
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
# Now install netlify-cli
npm install -g netlify-cli# Use netlify-cli without installing globally
npx netlify-cli login
npx netlify-cli deploy
npx netlify-cli deploy --prodIf you prefer to avoid CLI issues entirely:
# Make sure your code is on GitHub
git add .
git commit -m "Prepare for Netlify deployment"
git push origin mainConfigure build settings:
pnpm build.nextAfter deployment:
I'd suggest using Option 3 (npx) or the Dashboard method to avoid permission issues:
# Quick deployment with npx
npx netlify-cli login
npx netlify-cli deploy --prodWhich method would you prefer to try first?
I see you're trying to deploy with a specific directory and site name. There are a few issues with that command for a Next.js app. Let me help you fix it:
Next.js builds to .next, not dist. Use:
netlify deploy --prod --dir=.next --site=mailguardianNext.js apps need server-side rendering support. Try this instead:
# First, make sure you've built the app
pnpm build
# Then deploy (let Netlify auto-detect the framework)
netlify deploy --prod --site=mailguardian# Build first
pnpm build
# Deploy without specifying directory (let Netlify handle it)
netlify deploy --prod --site=mailguardianFor better Next.js support, you might want to:
# Install the Next.js plugin
npm install -D @netlify/plugin-nextjsThen update your netlify.toml:
[build]
command = "pnpm build"
[[plugins]]
package = "@netlify/plugin-nextjs"
[build.environment]
NODE_VERSION = "18"netlify.toml file to your projectRun the build command:
pnpm buildDeploy with the correct command:
netlify deploy --prod --site=mailguardianTry this approach and let me know what happens!