如何解决npm“错误:无效版本:"0.1"漏洞? [英] how to workaround npm "Error: Invalid version: "0.1" BUG?

查看:709
本文介绍了如何解决npm“错误:无效版本:"0.1"漏洞?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个nodejs包.运行npm install时,出现Error: Invalid version: "0.1消息,并且npm安装失败.

I am trying to build a nodejs package. When I run npm install I get Error: Invalid version: "0.1 message and npm installation fails.

我试图通过在模块目录的package.json文件中将"version": "0.1",替换为"version": "0.0.1",来手动修复错误,但是有许多模块包含无效的0.1版本.手动修复非常困难.

I tried to fix the error manually by replacing "version": "0.1", with "version": "0.0.1", in package.json files in modules directories but there are many modules that contain invalid 0.1 version. It's very hard to fix it manually.

是否有更简单的方法来解决它? 也许是awk,sed或其他bash脚本,它们以递归方式搜索package.json文件并将"version": "0.1",替换为"version": "0.0.1",帮助?

Is there a simpler way to fix it? Or maybe an awk, sed or other bash script that search for package.json files recursively and replace "version": "0.1", with "version": "0.0.1", help?

我已经检出了该线程 npm:为什么版本"0.1"无效?,以及在提问之前有很多其他

I already checked out this thread npm: Why is a version "0.1" invalid? and lots of others prior to asking question

推荐答案

find "dir" -type f -name package.json -print |
xargs sed -i 's/"version": "0.1"/"version": "0.0.1"/'

应该按照您的描述进行.将"dir"替换为您真正的起始目录,然后首先进行测试.

should do what you describe. Replace "dir" with whatever your real starting directory is and test it first of course.

这篇关于如何解决npm“错误:无效版本:"0.1"漏洞?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆