This question already has answers here:
npm install give Error: EPERM, unlink
(8 answers)
Closed 3 years ago.
I can't get npm install to work in an angular project. The install almost goes through but fails with
npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path C:\workspaces\my-project\my-module\node_modules\.staging\typescript-d1902bf5\lib\typescriptServices.js
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\workspaces\my-project\my-module\node_modules\.staging\typescript-d1902bf5\lib\typescriptServices.js'
npm ERR! [OperationalError: EPERM: operation not permitted, unlink 'C:\workspaces\my-project\my-module\node_modules\.staging\typescript-d1902bf5\lib\typescriptServices.js'] {
npm ERR! cause: [Error: EPERM: operation not permitted, unlink 'C:\workspaces\my-project\my-module\node_modules\.staging\typescript-d1902bf5\lib\typescriptServices.js'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\\workspaces\\my-project\my-module\\node_modules\\.staging\\typescript-d1902bf5\\lib\\typescriptServices.js'
npm ERR! },
npm ERR! stack: "Error: EPERM: operation not permitted, unlink 'C:\\workspaces\\my-project\my-module\\node_modules\\.staging\\typescript-d1902bf5\\lib\\typescriptServices.js'",
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\\workspaces\\my-project\my-module\\node_modules\\.staging\\typescript-d1902bf5\\lib\\typescriptServices.js',
npm ERR! parent: 'my-module'
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.
What I've tried:
Running from cmd, git bash and power shell both as a regular user and as admin
Deleting the node_modules folder and retrying
installing nvm for Windows and installing nodejs 12.13.0 LTS (which then installs npm), then trying npm install
uninstalling nvm for Windows and installing nodejs 12.13.0 LTS with the site's installer, npm i -g npm, npm install
excluding my workspaces dir in Windows security settings
npm cache verify, npm install
npm cache clean --force, npm install
Can anyone suggest something I may not have thought of? Unfortunately I can't post my package.json or .npmrc as the repository I'm using is not public but from the looks of the error it should be irrelevant.
Update
It looks like it might be a race condition. See here. I'm using npm version 6.13.0.
Another update
I've got other problems now but Jonathan Irvin's comment helped me, in particular this. I disabled windows indexing and gave all permissions to my user.
try npm unlink on the root directory of the project.
Related
I want to install npm, after running npm install on a fresh Laravel project I get this errors:
npm WARN deprecated popper.js#1.16.1: You can find the new Popper v2 at #popperjs/core, this package is dedicated to the legacy v1
npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path C:\Users\Andrei Bunea\Desktop\Laravel\Project\node_modules\.staging\errno-1258eed7\.travis.yml
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\Andrei Bunea\Desktop\Laravel\Project\node_modules\.staging\errno-1258eed7\.travis.yml'
npm ERR! [Error: EPERM: operation not permitted, unlink 'C:\Users\Andrei Bunea\Desktop\Laravel\Project\node_modules\.staging\errno-1258eed7\.travis.yml'] {
npm ERR! stack: "Error: EPERM: operation not permitted, unlink 'C:\\Users\\Andrei Bunea\\Desktop\\Laravel\\Project\\node_modules\\.staging\\errno-1258eed7\\.travis.yml'",
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\\Users\\Andrei Bunea\\Desktop\\Laravel\\Project\\node_modules\\.staging\\errno-1258eed7\\.travis.yml'
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\Andrei Bunea\AppData\Roaming\npm-cache\_logs\2020-04-25T17_06_43_120Z-debug.log
My npm version is v12.14.0 and my node version is v12.14.0 .
Delete the node_modules folder and package-lock.json file, then run npm install again.
You should run npm command as a super user.
Try,
sudo npm install
If it doesn't make sense try to delete node_modules and try npm install again
I am trying to create new angular project using the command ng new my-app. And the installed versions are listed below
Angular CLI : 6.0
Node version : 10.5.0
Npm : 6.1.0
I am getting the following error message,
ERR! path D:\ng\newapp\node_modules\.staging\typescript-4c0ca0e6\lib\lib.dom.d.ts
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'D:\ng\newapp\node_modules\.staging\typescript-4c0ca0e6\lib\lib.dom.d.ts'
npm ERR! { [Error: EPERM: operation not permitted, unlink 'D:\ng\newapp\node_modules\.staging\typescript-4c0ca0e6\lib\lib.dom.d.ts']
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, unlink 'D:\ng\newapp\node_modules\.staging\typescript-4c0ca0e6\lib\lib.dom.d.ts'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! 'D:\\ng\\newapp\\node_modules\\.staging\\typescript-4c0ca0e6\\lib\\lib.dom.d.ts' },
npm ERR! stack:
npm ERR! 'Error: EPERM: operation not permitted, unlink \'D:\\ng\\newapp\\node_modules\\.staging\\typescript-4c0ca0e6\\lib\\lib.dom.d.ts\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! 'D:\\ng\\newapp\\node_modules\\.staging\\typescript-4c0ca0e6\\lib\\lib.dom.d.ts',
npm ERR! parent: '#angular-devkit/build-optimizer' }
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 (though this is not recommended).
temporary fix, downgrade npm to 5.3
npm install npm#5.3 -g
Use administrator privileges. Error says you are not using admin CMD
Install packages after closing your code editor,
Are you using Node Cmd or any IDE(like VSCode) to create new project
try this command
npm i -g #angular/cli
ng new app-name
cd app-name.
ng serve
I've just generated a new Ionic1 app using "sidemenu" template.
No plugin added, no extra dependencies.
I get the error:
npm ERR! path C:\myApp\node_modules\.staging\cordova-android-dbc95b4b\node_modules\brace-expansion
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'C:\myApp\node_modules\.staging\cordova-android-dbc95b4b\node_modules\brace-expansion' -> 'C:\myApp\node_modules\.staging\brace-expansion-7416809b'
npm ERR! { Error: EPERM: operation not permitted, rename 'C:\myApp\node_modules\.staging\cordova-android-dbc95b4b\node_modules\brace-expansion' -> 'C:\myApp\node_modules\.staging\brace-expansion-7416809b'
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, rename 'C:\myApp\node_modules\.staging\cordova-android-dbc95b4b\node_modules\brace-expansion' -> 'C:\myApp\node_modules\.staging\brace-expansion-7416809b'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'C:\\nodejs\\fuckit\\node_modules\\.staging\\cordova-android-dbc95b4b\\node_modules\\brace-expansion',
npm ERR! dest: 'C:\\nodejs\\fuckit\\node_modules\\.staging\\brace-expansion-7416809b' },
npm ERR! stack: 'Error: EPERM: operation not permitted, rename \'C:\\nodejs\\fuckit\\node_modules\\.staging\\cordova-android-dbc95b4b\\node_modules\\brace-expansion\' -> \'C:\\nodejs\\fuckit\\node_modules\\.staging\\brace-expansion-7416809b\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'C:\\nodejs\\fuckit\\node_modules\\.staging\\cordova-android-dbc95b4b\\node_modules\\brace-expansion',
npm ERR! dest: 'C:\\nodejs\\fuckit\\node_modules\\.staging\\brace-expansion-7416809b',
npm ERR! parent: 'fuckit' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
I'm on a powershell running as admin.
node 8.9.4
npm 5.1.0
cordova 8.0.0
ionic 3.19.1
SOLVED(?): as the other 4-5 times I faced this problem, I solved but I do not know how. I simply tried to reinstall node (v8 and v9), npm (different versions), cordova (different versions), nvm. After ~15 hours completely wasted on this, I solved at the 4th complete refresh of the node/npm environment. NPM is simply a cruel nightmare.
EDIT: I suspect I solved because I changed the npm directory from
%APPDATA%/npm
to
C:\Program Files\nodejs
using the command
npm config set prefix "C:\Program Files\nodejs"
Surprisingly there are several tickets on the npm's GitHub issues page adressing your problem. Futhermore one of my teammates ran into exact the same issue as well today… So just have a look at their issues page or try one of the proposed solutions:
Update your npm to a newer version
Close your IDE e.g. VSCode or Visual Studio and npm install again
Kill all running node instances from your task manager and npm install again
…
This question already has answers here:
Fail to install npm package "npm ERR! errno -4048"
(21 answers)
Closed 5 years ago.
Windows 10 1703
Node 6.11.2
npm 5.4.0
Everytime I try to install an npm package (ex: npm i gulp-notify), I receive the following error:
npm ERR! path
C:\Users\web-dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json
npm ERR! code EPERM npm ERR! errno -4048 npm ERR!
syscall unlink npm ERR! Error: EPERM: operation not permitted,
unlink 'C:\Users\web-
dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json'
npm ERR! at Error (native) npm ERR! { Error: EPERM:
operation not permitted, unlink
'C:\Users\web-dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json'
npm ERR! at Error (native) npm ERR! stack: 'Error:
EPERM: operation not permitted, unlink
\'C:\Users\web-dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json\'\n
at Error (native)', npm ERR! errno: -4048, npm ERR!
code: 'EPERM', npm ERR! syscall: 'unlink', npm ERR!
path:
'C:\Users\web-dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json'
} npm ERR! npm ERR! Please try running this command again as
root/Administrator.
I ran cmd as administrator
I checked folder permissions
I cleared cache even though npm says it does it by itself
I changed npm prefix to C:\Users\User Name\AppData\Roaming\npm
Nothing helps.
Please advise.
Apparently I was trying to install packages locally instead of globally without the -g flag. Sorry about that. All is working now.
Still failed even after reinstall node and npm.
Here is the full error message
npm ERR! Linux 4.8.0-34-generic
npm ERR! argv "/home/lt1pchanifa/.nvm/versions/node/v6.9.3/bin/node" "/home/lt1pchanifa/.nvm/versions/node/v6.9.3/bin/npm" "install"
npm ERR! node v6.9.3
npm ERR! npm v4.0.5
npm ERR! path ../mkdirp/bin/cmd.js
npm ERR! code EPERM
npm ERR! errno -1
npm ERR! syscall symlink
npm ERR! Error: EPERM: operation not permitted, symlink '../mkdirp/bin/cmd.js' -> '/media/lt1pchanifa/B0D0-8B34/Edwin/thinkster-ng2/node_modules/#angular-cli/ast-tools/node_modules/.bin/mkdirp'
npm ERR! at Error (native)
npm ERR! { Error: EPERM: operation not permitted, symlink '../mkdirp/bin/cmd.js' -> '/media/lt1pchanifa/B0D0-8B34/Edwin/thinkster-ng2/node_modules/#angular-cli/ast-tools/node_modules/.bin/mkdirp'
npm ERR! at Error (native)
npm ERR! errno: -1,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'symlink',
npm ERR! path: '../mkdirp/bin/cmd.js',
npm ERR! dest: '/media/lt1pchanifa/B0D0-8B34/Edwin/thinkster-ng2/node_modules/#angular-cli/ast-tools/node_modules/.bin/mkdirp',
npm ERR! parent: '#angular-cli/ast-tools' }
You are trying to run npm in a linux platform within a Windows FAT32 folder.
/media/lt1pchanifa/B0D0-8B34/Edwin/thinkster-ng2
According to github issue, permission problems occur while trying to access Windows partition.
Try to move the project to Home directory which is EXT4 and run the command.
I haven't tried this myself but maybe you could skip creating symlinks if it's only problem with them.
npm install --no-bin-links
See more here:
npm install: when to use --no-bin-links?
Installing npm modules in a VM shared directory and grunt issues