每当我运行npm安装时,我就会得到
npm ERR! Invalid Version:
这是日志文件。
43 verbose stack TypeError: Invalid Version:
43 verbose stack at new SemVer (C:\Users\Myself\AppData\Roaming\npm\node_modules\npm\node_modules\semver\classes\semver.js:38:13)
43 verbose stack at compare (C:\Users\Myself\AppData\Roaming\npm\node_modules\npm\node_modules\semver\functions\compare.js:3:32)
43 verbose stack at Object.gte (C:\Users\Myself\AppData\Roaming\npm\node_modules\npm\node_modules\semver\functions\gte.js:2:30)
43 verbose stack at Node.canDedupe (C:\Users\Myself\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\node.js:1054:32)
43 verbose stack at PlaceDep.pruneDedupable (C:\Users\Myself\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\place-dep.js:465:14)
43 verbose stack at PlaceDep.placeInTree (C:\Users\Myself\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\place-dep.js:326:14)
43 verbose stack at PlaceDep.place (C:\Users\Myself\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\place-dep.js:214:10)
43 verbose stack at new PlaceDep (C:\Users\Myself\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\place-dep.js:71:10)
43 verbose stack at C:\Users\Myself\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:965:31
43 verbose stack at Array.map (<anonymous>)
44 verbose cwd C:\Users\Dont\Want\To\Reveal\This\Information
45 verbose Windows_NT 10.0.19042
46 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Myself\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "i" "-force"
47 verbose node v16.14.0
48 verbose npm v8.5.1
49 error Invalid Version:
50 verbose exit 1
51 timing npm Completed in 18500ms
我不明白什么版本是无效的?帮助!
发布于 2022-06-20 15:07:36
删除node_modules
和package-lock.json (OR yarn.lock)
为我解决了这个问题。
发布于 2022-06-09 15:20:45
npm@8.12也有同样的错误。通过降级到npm@8.5来修正。
发布于 2022-04-05 08:14:59
解决方案: --如果您在项目根目录中检查"package.json“文件,它可能缺少以下一个或全部属性:
对于版本,它必须是"x.x.x“形式,也就是说,在我的(也可能是您的)大小写"1.0.0”中
关于名称,您可以从"app.json“(例如,在我的例子中)获得它:
{
"expo": {
"name": "the-10-min",
"slug": "the-10-min",
"privacy": "public",
"platforms": [
"ios",
"android",
"web"
],
因此,在我的示例中,"package.json“文件中的name属性将是名称和版本值中的”-10-min“.Plug,然后运行命令"npm”。
https://stackoverflow.com/questions/71383116
复制相似问题