Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm publish causes 'Error: EPERM: operation not permitted, unlink ...', errno -4048

I'm trying to publish my NPM package: npm publish.

I get the following quite cryptic error:

npm ERR! path c:\Temp\npm-20936-b98f84c8\tmp\fromDir-02dd5394\package.tgz npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall unlink npm ERR! Error: EPERM: operation not permitted, unlink 'c:\Temp\npm-20936-b98f84c8\tmp\fromDir-02dd5394\package.tgz' npm ERR!     at Error (native) npm ERR!  { Error: EPERM: operation not permitted, unlink 'c:\Temp\npm-20936-b98f84c8\tmp\fromDir-02dd5394\package.tgz' npm ERR!     at Error (native) npm ERR!   cause: npm ERR!    { Error: EPERM: operation not permitted, unlink 'c:\Temp\npm-20936-b98f84c8\tmp\fromDir-02dd5394\package.tgz' npm ERR!        at Error (native) npm ERR!      errno: -4048, npm ERR!      code: 'EPERM', npm ERR!      syscall: 'unlink', npm ERR!      path: 'c:\\Temp\\npm-20936-b98f84c8\\tmp\\fromDir-02dd5394\\package.tgz' }, npm ERR!   isOperational: true, npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink \'c:\\Temp\\npm-20936-b98f84c8\\tmp\\fromDir-02dd5394\\package.tgz\'\n    at Error (native)', npm ERR!   errno: -4048, npm ERR!   code: 'EPERM', npm ERR!   syscall: 'unlink', npm ERR!   path: 'c:\\Temp\\npm-20936-b98f84c8\\tmp\\fromDir-02dd5394\\package.tgz' } npm ERR! npm ERR! Please try running this command again as root/Administrator. 

Tried running as admin - same error.

NPM version: 5.4.0

Node version: 6.11.1

OS: Windows 10

Any leads?

like image 310
Vaiden Avatar asked Sep 07 '17 07:09

Vaiden


People also ask

How fix npm install error?

If your npm is broken: On Mac or Linux, reinstall npm. Windows: If you're on Windows and you have a broken installation, the easiest thing to do is to reinstall node from the official installer (see this note about installing the latest stable version).

How do I update npm package manager?

Method 1: Using npm update command to update the node package manager. Method 2: Using npm@latest command to update the node package manager. Method 3: Using PPA repository (only for Linux). Method 4: Using cache cleaning & stable installing (only for Linux).


2 Answers

Silly me. The answer was in the docs all along.

In order to publish you need to be logged in from your NPM cli.

So either do npm login if you already have a user on npmjs.com, or npm adduser to create one.

I would, however, appreciate a more informative error message.

like image 68
Vaiden Avatar answered Sep 17 '22 14:09

Vaiden


I had the same problem on Windows.

The source of the problem is simple, it is access permission on folders and files. Click here

like image 29
Thiago Silva Avatar answered Sep 18 '22 14:09

Thiago Silva