npm Error in Vs code using os Linux(Ubuntu)? - node.js

enter image description here
protons#protons-HP-EliteBook-840-G3:~/Desktop/NH_Facility_Portal_V0$ npm install --legacy-peer-deps
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /home/protons/Desktop/NH_Facility_Portal_V0/node_modules/npm
npm ERR! dest /home/protons/Desktop/NH_Facility_Portal_V0/node_modules/.npm-IgU3U5Pl
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/home/protons/Desktop/NH_Facility_Portal_V0/node_modules/npm' -> '/home/protons/Desktop/NH_Facility_Portal_V0/node_modules/.npm-IgU3U5Pl'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/protons/.npm/_logs/2022-07-04T03_19_39_491Z-debug-0.log
protons#protons-HP-EliteBook-840-G3:~/Desktop/NH_Facility_Portal_V0$
protons#protons-HP-EliteBook-840-G3:~/Desktop/NH_Facility_Portal_V0$ sudo npm install --legacy-peer-deps
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /home/protons/Desktop/NH_Facility_Portal_V0/node_modules/npm
npm ERR! dest /home/protons/Desktop/NH_Facility_Portal_V0/node_modules/.npm-IgU3U5Pl
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/home/protons/Desktop/NH_Facility_Portal_V0/node_modules/npm' -> '/home/protons/Desktop/NH_Facility_Portal_V0/node_modules/.npm-IgU3U5Pl'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-07-04T03_20_01_694Z-debug-0.log
protons#protons-HP-EliteBook-840-G3:~/Desktop/NH_Facility_Portal_V0$ ^C
protons#protons-HP-EliteBook-840-G3:~/Desktop/NH_Facility_Portal_V0$

Try deleting the node_modules folder using rm -r node_modules and do npm install

Related

ENOTEMPTY error when I run npm run dev in my Nuxt3 project

When I run npm run dev I get this huge error message:
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /home/pavel/Documents/Web Projects/twitter-clone/node_modules/#babel/parser
npm ERR! dest /home/pavel/Documents/Web Projects/twitter-clone/node_modules/#babel/.parser-IknzzFET
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/home/pavel/Documents/Web Projects/twitter-clone/node_modules/#babel/parser' -> '/home/pavel/Documents/Web Projects/twitter-clone/node_modules/#babel/.parser-IknzzFET'

Issue installing yarn globally on Kali nethunter

npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/yarn
npm ERR! dest /usr/local/lib/node_modules/.yarn-Jrexx8nI
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/usr/local/lib/node_modules/yarn' -> '/usr/local/lib/node_modules/.yarn-Jrexx8nI'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-09-13T06_31_37_008Z-debug-0.log

Vs code not working in my linux npm err sowing?

protons#protons-HP-EliteBook-840-G3:~/Desktop/NH_Facility_Portal_V0$ sudo npm install
[sudo] password for protons:
npm notice
npm notice New minor version of npm available! 8.12.1 -> 8.13.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.13.2
npm notice Run npm install -g npm#8.13.2 to update!
npm notice
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-otp-input#2.4.0
npm ERR! Found: react#17.0.2
npm ERR! node_modules/react
npm ERR! react#"17.0.2" from the root project
npm ERR! peer react#">=16.0.0" from #ant-design/icons#4.7.0
npm ERR! node_modules/#ant-design/icons
npm ERR! #ant-design/icons#"^4.7.0" from the root project
npm ERR! 77 more (#emotion/react, #emotion/styled, #icons/material, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^16.2.0" from react-otp-input#2.4.0
npm ERR! node_modules/react-otp-input
npm ERR! react-otp-input#"^2.3.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react#16.14.0
npm ERR! node_modules/react
npm ERR! peer react#"^16.2.0" from react-otp-input#2.4.0
npm ERR! node_modules/react-otp-input
npm ERR! react-otp-input#"^2.3.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /root/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-07-01T06_16_23_962Z-debug-0.log
protons#protons-HP-EliteBook-840-G3:~/Desktop/NH_Facility_Portal_V0$ ^C
protons#protons-HP-EliteBook-840-G3:~/Desktop/NH_Facility_Portal_V0$ npm install -g npm#8.13.2
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/npm',
npm ERR! dest: '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/protons/.npm/_logs/2022-07-01T06_20_59_076Z-debug-0.log
protons#protons-HP-EliteBook-840-G3:~/Desktop/NH_Facility_Portal_V0$ sudo npm install -g npm#8.13.2
changed 24 packages, and audited 202 packages in 4s
11 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
protons#protons-HP-EliteBook-840-G3:~/Desktop/NH_Facility_Portal_V0$ sudo npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-otp-input#2.4.0
npm ERR! Found: react#17.0.2
npm ERR! node_modules/react
npm ERR! react#"17.0.2" from the root project
npm ERR! peer react#">=16.0.0" from #ant-design/icons#4.7.0
npm ERR! node_modules/#ant-design/icons
npm ERR! #ant-design/icons#"^4.7.0" from the root project
npm ERR! 77 more (#emotion/react, #emotion/styled, #icons/material, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^16.2.0" from react-otp-input#2.4.0
npm ERR! node_modules/react-otp-input
npm ERR! react-otp-input#"^2.3.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react#16.14.0
npm ERR! node_modules/react
npm ERR! peer react#"^16.2.0" from react-otp-input#2.4.0
npm ERR! node_modules/react-otp-input
npm ERR! react-otp-input#"^2.3.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /root/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-07-01T06_22_32_536Z-debug-0.log
protons#protons-HP-EliteBook-840-G3:~/Desktop/NH_Facility_Portal_V0$ ^C
protons#protons-HP-EliteBook-840-G3:~/Desktop/NH_Facility_Portal_V0$ npm fund
natty_hatty_facility_portal#0.1.0
protons#protons-HP-EliteBook-840-G3:~/Desktop/NH_Facility_Portal_V0$
First delete package-lock.json and node_modules folder
then run
npm install --legacy-peer-deps
or
sudo npm install --legacy-peer-deps
try with :
npm install --legacy-peer-deps
Run the following command.
sudo npm intall --force

eacces error whlle running npm install -g composer-cli

npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /home/akash2/.npm-packages/lib/node_modules/.staging/grpc-b403b8a1/node_modules/mkdirp
npm ERR! dest /home/akash2/.npm-packages/lib/node_modules/.staging/mkdirp-13f83417
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 1000:1000 "/home/akash2/.npm"
npm ERR! A complete log of this run can be found in:
npm ERR! /home/akash2/.npm/_logs/2021-05-07T05_37_52_411Z-debug.log
These are the errors. I am trying to fix this, but can't.

Cannot npm install -g without sudo changing prefix

I have done this: https://stackoverflow.com/a/21712034
now my npm config is the following:
npm config get prefix
/home/ranu/npm
But when I run npm install -g grunt-cli I get:
npm ERR! Error: EACCES, mkdir '/usr/lib/node_modules/grunt-cli'
npm ERR! { [Error: EACCES, mkdir '/usr/lib/node_modules/grunt-cli']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/lib/node_modules/grunt-cli',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/lib/node_modules/grunt-cli',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR! '/usr/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR! 'Object.oncomplete (fs.js:107:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.11.0-26-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "grunt-cli"
npm ERR! cwd /home/ranu
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! path /usr/lib/node_modules/grunt-cli
npm ERR! fstream_path /usr/lib/node_modules/grunt-cli
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/lib/node_modules/grunt-cli'
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/dir- writer.js:36:23
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/ranu/npm-debug.log
npm ERR! not ok code 0
Why is trying to install it on /usr/lib/node_modules/ if the prefix is set to /home/ranu/npm ?
UPDATE:
I could it make it work with the following command:
npm install --prefix="/home/ranu/npm" -g grunt-cli
There is any way to make it as a default?
Every time I get a new Machine, I run into this.
I'm citing this url fixing-npm-permissions because it's actually NPM's doc, but also because it was the only method that fixed my problem. Not the first search result but the simplest fix for me. I'm sure there are more robust fixes.
Rather than copying and pasting, I'm recommending you just go read it.
I followed step 1, and though according to them it should have worked. But, I ended up also using step 2 for the win.
You can use NVM (Node version manager) and you will never have to bother about sudo for npm commands

Resources