简体   繁体   English

npm 发布导致“错误:EPERM:不允许操作,取消链接...”,错误号 -4048

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

I'm trying to publish my NPM package: npm publish .我正在尝试发布我的 NPM 包: 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 NPM 版本:5.4.0

Node version: 6.11.1节点版本:6.11.1

OS: Windows 10操作系统:Windows 10

Any leads?任何线索?

Silly me.傻我。 The answer was in the docs all along .答案是在文档中 的所有一起

In order to publish you need to be logged in from your NPM cli.为了发布,您需要从 NPM cli 登录。

So either do npm login if you already have a user on npmjs.com , or npm adduser to create one.因此,如果您已经在npmjs.com上拥有用户,请执行npm login ,或者使用npm adduser创建一个用户。

I would, however, appreciate a more informative error message.但是,我希望提供更多信息丰富的错误消息。

I had the same problem on Windows.我在 Windows 上遇到了同样的问题。

The source of the problem is simple, it is access permission on folders and files.问题的根源很简单,就是文件夹和文件的访问权限。 Click here 点击这里

Here is my experience.这是我的经验。

I was working on Atom, and did file drag drop on Atom, it cause error.我在 Atom 上工作,并在 Atom 上进行了文件拖放,这会导致错误。 So I exit atom on Win10 and run npm i again.所以我在 Win10 上退出 atom 并再次运行npm i It was successful.它成功了。

Please turn off your editor or explorer which can restrict your project files and try again.请关闭您的编辑器或资源管理器,它们会限制您的项目文件,然后重试。

I changed to the new filesystem by remounting my windows drives.我通过重新安装 Windows 驱动器更改为新的文件系统。 After that no problems anymore.之后就没有问题了。 Refer to the following link .请参阅以下链接

In some cases it is a matter of pointing to the correct package.json file.在某些情况下,需要指向正确的package.json文件。 Had omitted the param in the before, causing the error.之前省略了参数,导致错误。

Before: npm publish之前: npm publish

After: npm publish C:\\Code\\my-proj\\dist\\@acme\\my-package之后: npm publish C:\\Code\\my-proj\\dist\\@acme\\my-package

People who are still struggling, check your package.json file if you have something like publishConfig initialized.还在苦苦挣扎的人,如果你已经初始化了诸如 publishConfig 之类的东西,请检查你的 package.json 文件。
Deleting this is what solved for me删除这是为我解决的问题

In my case problem was incorrect param npm publish --opt=123456 (typo opt => otp ... one time password - 2factor).在我的情况下,问题是不正确的参数npm publish --opt=123456 (typo opt => otp ...一次性密码 - 2factor)。 Terrible this misleading permission error The operation was rejected by your operating system.可怕的这种误导性权限错误The operation was rejected by your operating system. in case of wrong params.如果参数错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM