我用了最简单最笨的命令
npx create-react-app mia-app
cd mia-app
npm start
但是每次创建项目后都没有serviceWorker。有人可以帮助我吗?
但是,我已经尝试使用 npm create-create-app
来解决这个问题。
最佳答案
serviceWorker.js
不再包含在基本模板中,从 create-react-app 版本 4.0.something 开始。
遍历 create-react-app GitHub 问题,不断出现两个主要的解决方法:
npx create-react-app my-app --template cra-template-pwa
或 typescript :
npx create-react-app my-app --template cra-template-pwa-typescript
(其中 my-app
替换为您的应用名称)
- 如果您已有项目,create a dummy app and copy over the relevant code .如果您也这样做,请不要忘记从 index.js/index.tsx 复制初始化代码。
关于reactjs - 为什么我的 create-react-app 没有服务人员?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65183473/