Nodejs npm publish上个月error之后一直没好
Nodejs npm publish上个月error之后一直没好
ERR! registry error parsing json
ERR! registry error parsing json
ERR! registry error parsing json
ERR! publish Failed PUT 500
ERR! SyntaxError: Unexpected token A
ERR! An internal server error occurred. Please try again later
ERR! at Object.parse (native)
ERR! at RegClient.<anonymous> (C:\Program Files\nodejs\nod
.js:240:23)
ERR! at Request.callback (C:\Program Files\nodejs\node_mo
212:65)
ERR! at Request.self.callback (C:\Program Files\nodejs\nod
ERR! at Request.emit (events.js:98:17)
ERR! at Request.<anonymous> (C:\Program Files\nodejs\node
ERR! at Request.emit (events.js:117:20)
ERR! at IncomingMessage.<anonymous> (C:\Program Files\node
)
ERR! at IncomingMessage.emit (events.js:117:20)
ERR! at _stream_readable.js:929:16
ERR! If you need help, you may report this entire log,
ERR! including the npm and node versions, at:
ERR! <http://github.com/npm/npm/issues>
顺便问一下cnpm怎么publish 兄弟们,帮帮忙吧,一个月没更新了。 我的package.json文件
{
"name": "jdtpl-generator",
"version": "0.2.7",
"description": "a tool to generator project file system",
"scripts": {
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-travis": "mocha --reporter spec --bail --check-leaks test/"
},
"keywords": [
"generator",
"jdtpl"
],
"author": {
"name": "wuwei"
},
"license": "MIT",
"dependencies": {
"commander": "1.3.2",
"mkdirp": "0.3.5"
},
"preferGlobal": true,
"bin": {
"tpl": "./bin/tpl"
},
"devDependencies": {
"mkdirp": "~0.3.5",
"mocha": "~1.21.4",
"rimraf": "~2.2.8",
"should": "~4.0.4",
"supertest": "~0.13.0"
},
"engines": {
"node": ">= 0.8.0"
},
"files": [
"LICENSE",
"bin/",
"template/",
"test/"
],
"readme": "xxxxxx",
"readmeFilename": "README.md"
}
7 回复
你自己 json 写错了吧😒
借帖子也问个 npm publish 的问题,已经 npm publish 了新版本, npm install 强制版本号可以安装新版,但是 npm 的插件页面不更新,还是 0.0.1, npm install 不限制版本号时安装的也是旧版本。
第一次 publish ,请问是那个环节出了问题呢?
btw,已经升级三天 但没有更新了
难道大家的npm publish
都没问题么,再也不想复制黏贴了
对不起大家,因为我改密码了,但是错误提示也太扯淡了
根据你的描述,错误信息表明在尝试使用 npm publish 命令时遇到了服务器解析 JSON 的问题。这可能是由于多种原因造成的,比如网络不稳定、npm 服务端问题或者你的 package.json 文件有问题。
解决步骤
- 检查网络连接:确保你的网络连接正常,可以访问 npm 服务器。
- 更新 npm 版本:有时旧版本的 npm 可能会遇到兼容性问题。可以尝试更新 npm 到最新版本。
npm install -g npm[@latest](/user/latest)
- 检查 package.json:确认你的
package.json
没有语法错误。 - 清除 npm 缓存:清除 npm 缓存有时也能解决问题。
npm cache clean --force
- 重试:在排除以上可能问题后,再次尝试发布。
示例代码:更新 npm 并清除缓存
# 更新 npm
npm install -g npm[@latest](/user/latest)
# 清除 npm 缓存
npm cache clean --force
# 尝试重新发布
npm publish
如果上述步骤仍然无法解决你的问题,建议查看 npm 的官方文档或 GitHub Issues 页面寻求帮助。
关于 cnpm
cnpm
是一个由淘宝团队维护的 npm 镜像,如果你在中国,可能会因为网络原因导致直接访问 npm 速度慢或失败。你可以安装并使用 cnpm:
npm install -g cnpm --registry=https://registry.npmmirror.com
然后用 cnpm
来代替 npm
的命令:
cnpm publish
这样可能会提升你的发布速度和成功率。