Fail to install npm package “npm ERR! errno -4048”

2019-01-08 18:26发布

I'm trying to install npm package (node-xmpp-server) but it fail to install. previously when I'm trying to install a package that is install globally instead of locally, but now it's not installing at all.
Plz Help me.

npm install node-xmpp-server
error is: npm ERR! errno -4048
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "c:\Program Files\nodejs\node.exe" "c:\Program
Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "node-xmpp-server"

npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! path c:\Users\Jaseem Abbas\Documents\node_modules\node- xmpp-server\examples
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! Error: EPERM, unlink 'c:\Users\Jaseem Abbas\Documents\node_modules\node-xmpp-server\examples'

npm ERR! at Error (native)
npm ERR! { [Error: EPERM, unlink 'c:\Users\Jaseem Abbas\Documents\node_modules\node-xmpp-server\examples']

npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! path: 'c:\Users\Jaseem Abbas\Documents\node_modules\node-xmpp-server\examples' } npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EPERM, unlink 'c:\Users\Jaseem Abbas\Documents\node_modules\node-xmpp-server\examples'

npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EPERM, unlink 'c:\Users\Jaseem
Abbas\Documents\node_modules\node-xmpp-server\examples']
npm ERR! error rolling back errno: -4048,
npm ERR! error rolling back code: 'EPERM',
npm ERR! error rolling back path: 'c:\Users\Jaseem Abbas\Documents\node_modules\node-xmpp-server\examples' }

17条回答
Explosion°爆炸
2楼-- · 2019-01-08 18:49

Someone said it was due to npm bug https://github.com/npm/npm/issues/9696

Adding "--force" to install allegedly works around the problem.

查看更多
迷人小祖宗
3楼-- · 2019-01-08 18:51

I changed the npm version and this did not happen again

查看更多
We Are One
4楼-- · 2019-01-08 18:53

It seems that this error can manifest for more than one reason, so there probably won't be a single fix which works for everyone.

However, concurrency issues often are the cause of the failing installs. According to the accumulated wisdom in one of the related npm issue threads, which has received nearly 180 comments so far, the underlying problem is

a race condition between asynchronous I/O operations accessing the same files on the harddisk. You can certainly influence it by cleaning up the harddisk e.g. with "npm cache verify" or moving the project to a SSD, but this does not solve the root cause of the problem.

Likewise, closing the IDE or disabling the virus scanner works sometimes, for some people, but does not really fix the problem for good if concurrency issues are behind it.

A patch has landed in npm 5.6.0. According to initial reports, it seems to do the trick. So if your npm --version is lower, update to 5.6.0 (or whatever the current version is when you read this):

npm uninstall -g npm
npm install -g npm@5.6.0

as suggested here.

If that doesn't help, then perhaps a file lock is the true cause. And closing the IDE, or disabling the virus scanner temporarily, or some similar action is indeed the way to go, as @Oly has said above.

查看更多
霸刀☆藐视天下
5楼-- · 2019-01-08 18:54

Upgrade npm to 5.4.2 it will fix this problem.

Command to install : npm i -g npm@5.4.2 or npm i -g npm

if still doesn't work try clearing cache using npm cache clean

you can use force like this npm cache clean --force

查看更多
不美不萌又怎样
6楼-- · 2019-01-08 18:54

I just run npm cache clean, and worked for me

查看更多
老娘就宠你
7楼-- · 2019-01-08 18:58

Had the same issue Closing visual studio solved the problem

查看更多
登录 后发表回答