1、Redux 下载
下载地址
git clone https://github.com/reactjs/redux.git
进入examples/todos,下载依赖:
npm install
2、问题复现及解决
执行命令
npm run start
此时终端报错:
Error: error:0308010C:digital envelope routines::unsupported
解决方法:
打开 package.json,修改 scripts
"scripts": {
"start": "react-scripts start",
"build": "export react-scripts build",
"eject": "react-scripts eject",
"test": "react-scripts test --env=node"
},
如果是mac,则改为:
"scripts": {
"start": "export NODE_OPTIONS=--openssl-legacy-provider;react-scripts start",
"build": "export NODE_OPTIONS=--openssl-legacy-provider;react-scripts build",
"eject": "react-scripts eject",
"test": "react-scripts test --env=node"
},
如果是window,则改为:
"scripts": {
"start": "set NODE_OPTIONS=--openssl-legacy-provider && react-scripts start",
"build": "set NODE_OPTIONS=--openssl-legacy-provider && react-scripts build",
"eject": "react-scripts eject",
"test": "react-scripts test --env=node"
},
再次运行npm run start
,报错
Failed to load config "react-app" to extend from.
这里我是将 redux/.eslintrc.cjs 文件里面的内容给注释了
module.exports = {
// extends: 'react-app',
// ...
}
此时再次运行 npm run start
,项目正常启动