我想为我的应用程序安装react-native-elements
,但在cmd提示符中输入install命令后,它会给出以下错误:
npm ERR! Unexpected end of JSON input while parsing near '...webpack-loader":"^3.3'
npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersDEAppDataRoamingnpm-cache_logs2020-04-11T06_21_21_206Z-debug.log
并且在2020-04-11T06_21_21_206Z-debug.log
中
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '--save',
1 verbose cli 'react-native-elements' ]
2 info using npm@5.6.0
3 info using node@v8.11.1
4 verbose npm-session 19d809f3b42b5934
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npmjs.org/react-native-elements 656ms (from cache)
8 silly fetchPackageMetaData error for react-native-elements@latest Unexpected end of JSON input while parsing near '...webpack-loader":"^3.3'
9 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...webpack-loader":"^3.3'
9 verbose stack at JSON.parse (<anonymous>)
9 verbose stack at parseJson (C:Program Filesnodejsnode_modulesnpmnode_modulespacotenode_modulesmake-fetch-happennode_modulesnode-fetch-npmnode_modulesjson-parse-better-errorsindex.js:7:17)
9 verbose stack at consumeBody.call.then.buffer (C:Program Filesnodejsnode_modulesnpmnode_modulespacotenode_modulesmake-fetch-happennode_modulesnode-fetch-npmsrcbody.js:96:50)
9 verbose stack at <anonymous>
9 verbose stack at process._tickCallback (internal/process/next_tick.js:188:7)
10 verbose cwd E:Projecttest
11 verbose Windows_NT 10.0.17134
12 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "--save" "react-native-elements"
13 verbose node v8.11.1
14 verbose npm v5.6.0
15 error Unexpected end of JSON input while parsing near '...webpack-loader":"^3.3'
16 verbose exit [ 1, true ]
所有其他库都已成功安装。只有react-native-elements
出现错误。
尝试安装旧版本的react本机元素。
我通过使用npm install react-native-elements@3.0.0
安装3.0.0版本解决了这个问题。
通过只执行npm install react-native-elements
(没有固定版本(,npm试图安装反作用原生元素的3.3.2版本。
另一种选择是使用--legacy-peer-deps
标志:
npm install --legacy-peer-deps
或
npm install react-native-elements --legacy-peer-deps
首先,尝试
npm cache clean --force
然后安装react原生元素
npm install react-native-elements