简体   繁体   English

npm 错误! 此 package 已标记为私有

[英]npm ERR! This package has been marked as private

I try to publish my angular library on npm.我尝试在 npm 上发布我的 angular 库。

But i get error但我得到错误

npm ERR. This package has been marked as private. Remove the 'private' field from the package.json to publish it.

But i don't have any private field in my package.json file但是我的 package.json 文件中没有任何私有字段

My package.json file of my library looks like this:我的库的 package.json 文件如下所示:

{
  "name": "@myfirst_mylastname/testlib123",
  "version": "0.0.1",
  "peerDependencies": {
    "@angular/common": "^11.1.2",
    "@angular/core": "^11.1.2"
  },
  "dependencies": {
    "tslib": "^2.0.0"
  },
  "description": "Test library",
  "author": {"name":"test name"},
  "keywords": ["test library"],
}

what i tried我试过的

I thought that private is always by default and i added "private":"false" to my package.json file but i get same error on npm publish.我认为私有总是默认的,我在我的 package.json 文件中添加了“private”:“false”,但我在 npm 发布时遇到了同样的错误。

I googled and i found answers where they say - make private field true or false in the package.json file.我用谷歌搜索并找到了他们所说的答案 - 在googled文件中设置私有字段为真或假。 I tried that but without success我试过了,但没有成功

Why is that?这是为什么? How can be solved?怎么能解决?

In case this is a problem for anyone else, the error thrown by NPM when publishing a scoped package is misleading.如果这对其他人来说是个问题,那么 NPM 在发布作用域 package 时抛出的错误具有误导性。

There may be no "private" field in your package.json file, however scoped packages have their access property set to restricted by default, whereas normal packages are public by default ( https://docs.npmjs.com/cli/v8/commands/npm-publish#access ).您的package.json文件中可能没有“私有”字段,但是默认情况下,作用域包的访问属性设置为restricted ,而普通包默认情况下是public的 ( Z5E056C500A1C4B6A7110/docsnADEv.com/B.命令/npm-publish#access )。

To be able to publish your scoped package, ensure first that your terminal is in the root of the package - the publish command only affects the directory that you are in. Then use a flag to set its access property when publishing:为了能够发布您的作用域 package,首先确保您的终端位于 package 的根目录中 - 发布命令仅影响您所在的目录。然后在发布时使用标志设置其访问属性:

npm publish --access=public

You should also be able to set the default access value for your package using the command您还应该能够使用命令为 package 设置默认访问值

npm access public @myfirst_mylastname/testlib123

which would allow you to publish without specifying the flag.这将允许您在不指定标志的情况下发布。 ( https://docs.npmjs.com/cli/v8/commands/npm-access#details ) https://docs.npmjs.com/cli/v8/commands/npm-access#details

暂无
暂无

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

相关问题 npm 错误! 404 Not Found for Private Package 在 gitLab CICD 上安装时 - npm ERR! 404 Not Found for Private Package while installing on gitLab CICD 从私有 github 存储库安装 npm 包 npm ERR! 代码ENOENT - install npm package from private github repository npm ERR! code ENOENT 是否可以仅在尚未安装npm软件包的情况下安装它? - Is it possible to install npm package only if it has not been already installed? npm ERR! 安装软件包时 - npm ERR! when installing package npm WARN不推荐使用npmconf@2.1.2:此软件包已重新集成到npm中,并且相对于npm已过时 - npm WARN deprecated npmconf@2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm npm WARN弃用了npmconf@2.1.2:这个软件包已经重新集成到npm中,现在已经过时了npm - npm WARN deprecated npmconf@2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm 呃! 尝试将包发布到 npm 时出现 403 - ERR! 403 when trying to publish a package to npm package.json更新后,GitLab CI中仅“ npm install” - Only 'npm install' in GitLab CI when package.json has been updated 如果package.json文件已更新,用户应运行什么NPM命令? - What NPM command should users run if the package.json file has been updated? npm package 无法安装“npm ERR:错误:EACCES:权限被拒绝” - npm package fails to install "npm ERR! Error: EACCES: permission denied"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM