Why do I get these errors when I type npm install in the terminal? - npm

Whenever I install anything with npm, I get the following error list:
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Users\Firstname~1
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Users\Firstname~1'
npm ERR! [OperationalError: EPERM: operation not permitted, mkdir 'C:\Users\Firstname~1'] {
npm ERR! cause: [Error: EPERM: operation not permitted, mkdir 'C:\Users\Firstname~1'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'C:\\Users\\Firstname~1'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'C:\\Users\\Firstname~1'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
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.
How can I resolve this? How can I run npm install by administrator?

Looks like an npm misconfiguration issue.
Ideally, you can configure it to use only directories that your user has access, so you won't need admin privileges just to install global packages.
First, check what's the npm prefix using a command like
npm config ls -l
I bet it will show something like
prefix = "C:\\Users\\"
Try to create at C:\Users{username}\ where {username} is your own, a .npmrc file with an entry like
prefix = "C:\\Users\\{username}\\some_dir_you_have_access"
Then use -g like npm install -g package, this way npm will try to install global packages in the path specified by "prefix" you've defined.
npm folders are documented here https://docs.npmjs.com/cli/v7/configuring-npm/folders

Related

Npm error occuring when trying to run npm install -g npm

Receiving the foillowing error, when I try to search C:\Users\harka\AppData\Roaming\npm\node_modules\npm\node_modules.node-gyp.DELETE\node_modules#npmcli via run app it tell mes that it cannot find the file
error when using run command to find path
Picture of error code in cmd
C:\GreaterWMS\templates>npm install -g npm
npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path C:\Users\harka\AppData\Roaming\npm\node_modules\npm\node_modules.node-gyp.DELETE\node_modules#npmcli
npm ERR! dest C:\Users\harka\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules#npmcli
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\harka\AppData\Roaming\npm\node_modules\npm\node_modules.node-gyp.DELETE\node_modules#npmcli' -> 'C:\Users\harka\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules#npmcli'
npm ERR! [OperationalError: EPERM: operation not permitted, rename 'C:\Users\harka\AppData\Roaming\npm\node_modules\npm\node_modules.node-gyp.DELETE\node_modules#npmcli' -> 'C:\Users\harka\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules#npmcli'] {
npm ERR! cause: [Error: EPERM: operation not permitted, rename 'C:\Users\harka\AppData\Roaming\npm\node_modules\npm\node_modules.node-gyp.DELETE\node_modules#npmcli' -> 'C:\Users\harka\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules#npmcli'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'C:\Users\harka\AppData\Roaming\npm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\#npmcli',
npm ERR! dest: 'C:\Users\harka\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules\#npmcli'
npm ERR! },
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'C:\Users\harka\AppData\Roaming\npm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\#npmcli',
npm ERR! dest: 'C:\Users\harka\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules\#npmcli',
npm ERR! parent: 'npm'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
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! C:\Users\harka\AppData\Roaming\npm-cache_logs\2022-11-15T14_28_23_790Z-debug.log
I have no idea how to fix this error, I have tried creating a temporary cache I have wiped my entire computer and reset and restarted the entire process from scratch but I keep receiving this same error.
I have turned off my firewall
2.I have turned off all anti virus software
3.I have tried deleting the Roaming data npm folder and tried to reinstall npm, but everything that I try to do nothing will fix this error.
thought maybe because my user for my microsoft is 2 names (First and Last, I then turn my pc into a local machine so it the user would only be "harka"
And have you installed npm previously, can you run for example npm -v ? if not, that means u don't have npm installed at all and you trying to use it to install npm (if I am not mistaken)
Then assuming you are using windows, the best way to install npm to windows is to download node.js from their official website, which installs npm as well.

I couldn't install import sass into my project

when I run the command
npm install --save-dev sass
from bootstrap-v5 folder I'm getting this error shown below
npm ERR! code EPERM
npm ERR! syscall symlink
npm ERR! path ../sass/sass.js
npm ERR! dest/storage/emulated/0/Android/data/io.spck/files/New_Portfolio_project/bootstrap-v5/node_modules/.bin/sass
npm ERR! errno -1
npm ERR! Error: EPERM: operation not permitted, symlink '../sass/sass.js' -> '/storage/emulated/0/Android/data/io.spck/files/New_Portfolio_project/bootstrap-v5/node_modules/.bin/sass'
npm ERR! [Error: EPERM: operation not permitted, symlink '../sass/sass.js' -> '/storage/emulated/0/Android/data/io.spck/files/New_Portfolio_project/bootstrap-v5/node_modules/.bin/sass'] {
npm ERR! errno: -1,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'symlink',
npm ERR! path: '../sass/sass.js',
npm ERR! dest: '/storage/emulated/0/Android/data/io.spck/files/New_Portfolio_project/bootstrap-v5/node_modules/.bin/sass'
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! /data/data/com.termux/files/home/.npm/_logs/2021-09-29T17_41_24_947Z-debug.log
But I was able to install sass globally with the command npm i -g sass.
I'm just trying this out for the first time. And, is there any way to import sass to my project as I have already installed sass globally?
Try npm install node-sass instead of npm install sass

npm ERR code EPERM syscall unlink while executing npm install

Got the following error while executing npm install
node version 12.16.2
Running cmd as administrator
npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path D:\Projects\BTP\Medical-Project\client\node_modules\.staging\npm-9e4fc1a9\man\man5\package-locks.5
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'D:\Projects\BTP\Medical-Project\client\node_modules\.staging\npm-9e4fc1a9\man\man5\package-locks.5'
npm ERR! [OperationalError: EPERM: operation not permitted, unlink 'D:\Projects\BTP\Medical-Project\client\node_modules\.staging\npm-9e4fc1a9\man\man5\package-locks.5'] {
npm ERR! cause: [Error: EPERM: operation not permitted, unlink 'D:\Projects\BTP\Medical-Project\client\node_modules\.staging\npm-9e4fc1a9\man\man5\package-locks.5'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'D:\\Projects\\BTP\\Medical-Project\\client\\node_modules\\.staging\\npm-9e4fc1a9\\man\\man5\\package-locks.5'
npm ERR! },
npm ERR! stack: "Error: EPERM: operation not permitted, unlink 'D:\\Projects\\BTP\\Medical-Project\\client\\node_modules\\.staging\\npm-9e4fc1a9\\man\\man5\\package-locks.5'",
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'D:\\Projects\\BTP\\Medical-Project\\client\\node_modules\\.staging\\npm-9e4fc1a9\\man\\man5\\package-locks.5',
npm ERR! parent: 'client'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
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! C:\Users\kz\AppData\Roaming\npm-cache\_logs\2021-04-01T18_15_01_424Z-debug.log
I tried :
npm cache clean --force
deleted node_modules and installed again
disabled antivirus
Restarting laptop :)
I was able to fix this by
Closing any open prompts and editors eg. VSCode.
Opening the terminal or CMD as admin and running npm-install again.
I think the IDE is 'locking a file'.

'expo' is not recognized as an internal or external command, operable program or batch file

I am getting this error when I try to use expo commands.
npm ERR! code EPERM npm ERR! syscall rename npm ERR! path
C:\Users\Sri\AppData\Roaming\npm\node_modules\expo-cli npm ERR! dest
C:\Users\Sri\AppData\Roaming\npm\node_modules.expo-cli-JgrrLjT2 npm
ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted,
rename 'C:\Users\Sri\AppData\Roaming\npm\node_modules\expo-cli' ->
'C:\Users\Sri\AppData\Roaming\npm\node_modules.expo-cli-JgrrLjT2' npm
ERR! [Error: EPERM: operation not permitted, rename
'C:\Users\Sri\AppData\Roaming\npm\node_modules\expo-cli' ->
'C:\Users\Sri\AppData\Roaming\npm\node_modules.expo-cli-JgrrLjT2'] {
npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall:
'rename', npm ERR! path:
'C:\Users\Sri\AppData\Roaming\npm\node_modules\expo-cli', npm
ERR! dest:
'C:\Users\Sri\AppData\Roaming\npm\node_modules\.expo-cli-JgrrLjT2'
npm ERR! } npm ERR! npm ERR! The operation was rejected by your
operating system. npm ERR! It's possible that the file was already in
use (by a text editor or antivirus), npm ERR! or that you lack
permissions to access it. 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!
C:\Users\Sri\AppData\Local\npm-cache_logs\2020-12-31T06_02_09_505Z-debug.log
C:\Users\Sri\AppData\Roaming\npm\node_modules\expo-cli
I followed the above path and found that expo-cli folder was there but when I try to init or uninstall expo it says 'expo' is not recognized as internal or external command.
if your in right directory perhaps the binary you are trying to execute does'nt exist there ,maybe the executable is named something else and if you are trying from another directory you should add the executable to system variables here's the link to do so

npm ERR! errno -4048

After 1 week break, I opened my pc again and when I want to 'expo start' from command window I get error like " 'expo' is not recognized as an internal or external command,operable program or batch file. " . And I tried to uninstall and install expo again and when I call " npm install --global expo-cli " I got this error.
npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path C:\Users\tuna\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\.xdl.DELETE\binaries\windows\adb\AdbWinUsbApi.dll
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\tuna\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\.xdl.DELETE\binaries\windows\adb\AdbWinUsbApi.dll'
npm ERR! [OperationalError: EPERM: operation not permitted, unlink 'C:\Users\tuna\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\.xdl.DELETE\binaries\windows\adb\AdbWinUsbApi.dll'] {
npm ERR! cause: [Error: EPERM: operation not permitted, unlink 'C:\Users\tuna\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\.xdl.DELETE\binaries\windows\adb\AdbWinUsbApi.dll'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\\Users\\tuna\\AppData\\Roaming\\npm\\node_modules\\expo-cli\\node_modules\\#expo\\.xdl.DELETE\\binaries\\windows\\adb\\AdbWinUsbApi.dll'
npm ERR! },
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\\Users\\tuna\\AppData\\Roaming\\npm\\node_modules\\expo-cli\\node_modules\\#expo\\.xdl.DELETE\\binaries\\windows\\adb\\AdbWinUsbApi.dll',
npm ERR! parent: 'expo-cli'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
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! C:\Users\tuna\AppData\Roaming\npm-cache\_logs\2020-10-03T15_36_23_690Z-debug.log
I couldnt find any solution that looks like my problem. Anybody has an idea to solve this problem.
Thanks in advance.