【发布时间】:2021-02-25 15:04:18
【问题描述】:
我在 npm 上创建了一个新组织,我正在尝试将我的 react 组件发布为一个作用域包,以便我的团队可以在所有其他应用程序内部使用相同的组件。
在运行npm publish 命令时,我得到以下信息
npm ERR! code EPRIVATE
npm ERR! This package has been marked as private
npm ERR! Remove the 'private' field from the package.json to publish it.
npm ERR! A complete log of this run can be found in:
我的 package.json 看起来像这样
{
"name": "my-package-name",
"version": "1.0.0",
"private": true,
"main": "dist/AllExports.js",
"module": "dist/AllExports.js",
"dependencies": {
"@material-ui/core": "^4.11.2",
"@material-ui/icons": "^4.11.2",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.4.0",
"axios": "^0.21.0",
"package1217721": "^1.2.7",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-hook-form": "^6.13.0",
"react-redux": "^7.2.2",
"react-scripts": "4.0.1",
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "set NODE_ENV=production && rm -rf dist && mkdir dist && npx babel src/components --out-dir dist",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"proxy": "http://localhost:5000",
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/preset-react": "^7.12.10"
}
}
.babelrc 文件看起来像这样
//.babelrc
{
"presets": [
"@babel/preset-react"
]
}
.npmrc 看起来像这样
registry=http://registry.npmjs.org/
scope=myscopename
@myscopename:registry=http://registry.npmjs.org
我也试过了
- 注销然后重新登录。
- 卸载 node_modules 然后重新安装。
- npm 更新了吗
- 也清除了 npm 缓存
【问题讨论】:
-
你用的是什么版本的 npm?
-
@JonathanIrwin 我使用的是 6.14.9
标签: reactjs npm node-modules npm-publish