This question already has an answer here:
- npm: Why is a version “0.1” invalid? 3 answers
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.
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.
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?
EDIT: I already checked out this thread npm: Why is a version "0.1" invalid? and lots of others prior to asking question
Use
jq
:Since in-place editing is not yet available in released versions of
jq
, combining this withfind
to process allpackage.json
files in a directory tree requires a subshell to redirect thejq
output to a temporary file. For example:should do what you describe. Replace "dir" with whatever your real starting directory is and test it first of course.