在我运行npm run时,克隆了React样板之后,设置其显示错误。
PS D:\React\react-boilerplate> npm run setup
> react-boilerplate@4.0.0 presetup D:\React\react-boilerplate
> npm i chalk shelljs
> pngquant-bin@5.0.2 postinstall D:\React\react-boilerplate\node_modules\pngquant-bin
> node lib/install.js
‼ Command failed: D:\React\react-boilerplate\node_modules\pngquant-bin\vendor\pngquant.exe --version
‼ pngquant pre-build test failed
i compiling from source
× Error: pngquant failed to build, make sure that libpng-dev is installed
at Promise.all.then.arr (D:\React\react-boilerplate\node_modules\execa\index.js:231:11)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
npm WARN connected-react-router@6.4.0 requires a peer of react-redux@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN jest-styled-components@6.3.1 requires a peer of styled-components@^2.0.0 || ^3.0.2 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pngquant-bin@5.0.2 postinstall: `node lib/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pngquant-bin@5.0.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Coder\AppData\Roaming\npm-cache\_logs\2019-07-17T11_03_29_890Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-boilerplate@4.0.0 presetup: `npm i chalk shelljs`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-boilerplate@4.0.0 presetup script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Coder\AppData\Roaming\npm-cache\_logs\2019-07-17T11_03_30_260Z-debug.log
答案 0 :(得分:-1)
您必须先运行export const fetchGitHubDataAsync = () => {
return dispatch => {
fetch('https://api.github.com/search/topics?q=javascript', {
headers: {
'Accept': 'application/vnd.github.mercy-preview+json'
}
})
.then(res => res.json())
.then(json => {console.log('json', json.items.slice(0, 5));
return dispatch({type: 'FETCH_GITHUB_DATA', payload: json.items.slice(0, 5)})});
}
}
,然后运行npm i chalk shelljs