1

我已经使用https://nodejs.org/en/download/上的 msi 文件在Windows 7上安装了 nodejs ,节点:v6.11.3(包括 npm 3.10.10)

试图运行我的应用程序

npm start

我得到错误

D:\dev_projects\nodejs_apps\react-practice>npm start
npm ERR! Windows_NT 6.1.7600
npm ERR! argv "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin       \\npm-cli.js" "start"
npm ERR! node v6.11.3
npm ERR! npm  v3.10.10

npm ERR! Invalid version: "y"
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     D:\dev_projects\nodejs_apps\react-practice\npm-debug.log

D:\dev_projects\nodejs_apps\react-practice\npm-debug.log中的文件包含:

0 info it worked if it ends with ok
1 verbose cli [ 'D:\\nodejs\\node.exe',
1 verbose cli   'D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@3.10.10
3 info using node@v6.11.3
4 verbose stack Error: Invalid version: "y"
4 verbose stack     at Object.fixVersionField (D:\nodejs\node_modules\npm\node_modules\normalize-package-data\lib\fixer.js:191:13)
4 verbose stack     at D:\nodejs\node_modules\npm\node_modules\normalize-package-data\lib\normalize.js:32:38
4 verbose stack     at Array.forEach (native)
4 verbose stack     at normalize (D:\nodejs\node_modules\npm\node_modules\normalize-package-data\lib\normalize.js:31:15)
4 verbose stack     at final (D:\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:349:5)
4 verbose stack     at then (D:\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:124:5)
4 verbose stack     at ReadFileContext.<anonymous> (D:\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:308:29)
4 verbose stack     at ReadFileContext.callback (D:\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16)
4 verbose stack     at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:367:13)
5 verbose cwd D:\dev_projects\nodejs_apps\react-practice
6 error Windows_NT 6.1.7600
7 error argv "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
8 error node v6.11.3
9 error npm  v3.10.10
10 error Invalid version: "y"
11 error If you need help, you may report this error at:
11 error     <https://github.com/npm/npm/issues>
12 verbose exit [ 1, true ]

然后我将 npm 升级到使用npm install -g npm 版本5.4.2

我再次运行 npm start ,这似乎已经解决npm ERR! Windows_NT 6.1.7600了错误,但错误npm ERR! Invalid version: "y"是持久的:

D:\dev_projects\nodejs_apps\react-practice>npm start
npm ERR! Invalid version: "y"

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\repair\AppData\Roaming\npm-cache\_logs  \2017-09-17T10_53_27_236Z-debug.log

上述2017-09-17T10_53_27_236Z-debug.log-debug.log文件包含以下内容:

0 info it worked if it ends with ok
1 verbose cli [ 'D:\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\repair\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@5.4.2
3 info using node@v6.11.3
4 verbose stack Error: Invalid version: "y"
4 verbose stack     at Object.fixVersionField (C:\Users\repair\AppData\Roaming\npm\node_modules\npm\node_modules\normalize-package-data\lib\fixer.js:191:13)
4 verbose stack     at C:\Users\repair\AppData\Roaming\npm\node_modules\npm\node_modules\normalize-package-data\lib\normalize.js:32:38
4 verbose stack     at Array.forEach (native)
4 verbose stack     at normalize (C:\Users\repair\AppData\Roaming\npm\node_modules\npm\node_modules\normalize-package-data\lib\normalize.js:31:15)
4 verbose stack     at final (C:\Users\repair\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:395:5)
4 verbose stack     at then (C:\Users\repair\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:160:5)
4 verbose stack     at C:\Users\repair\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:280:12
4 verbose stack     at C:\Users\repair\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16
4 verbose stack     at tryToString (fs.js:457:3)
4 verbose stack     at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:444:12)
5 verbose cwd D:\dev_projects\nodejs_apps\react-practice
6 verbose Windows_NT 6.1.7600
7 verbose argv "D:\\nodejs\\node.exe" "C:\\Users\\repair\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
8 verbose node v6.11.3
9 verbose npm  v5.4.2
10 error Invalid version: "y"
11 verbose exit [ 1, true ]

所以升级npm似乎并不能解决这个问题快速谷歌搜索:npm ERR!无效版本:“y” 返回与匹配 npm 版本号和 semver 规则相关的解决方案。

4

1 回答 1

1

我的 package.Json 有 "version": "0" 并且需要是 "version": "0.0.1"

于 2019-05-14T08:26:20.840 回答