在运行`npx create-react-app`后,serviceWorker.js文件丢失,

n53p2ov0  于 2个月前  发布在  React
关注(0)|答案(6)|浏览(36)

我已经运行了两次npx create-react-app命令,但在/src目录下两次都找不到serviceWorker.js文件。因此,当我尝试从'./serviceWorker'导入*作为serviceWorker时,我得到了一个模块未找到的错误。

hpxqektj

hpxqektj1#

尝试运行 npx create-react-app my-app --template cra-template-pwa

ruyhziif

ruyhziif2#

你是否知道这个文件在哪里有记录?README仍然期望有一个serviceWorker.js文件在那里,而且我在文档中没有看到任何关于它被移除或者官方说你需要手动创建一个的声明,只有人们在提出的问题中的解决方法。

6fe3ivhb

6fe3ivhb3#

我已经运行了两次$npx create-react-app$命令,但在两次中,/src目录下的serviceWorker.js文件都丢失了。所以当我尝试从'./serviceWorker'导入所有内容时,我得到了一个模块未找到的错误。

对于TypeScript:

$npx create-react-app my-app --template cra-template-pwa-typescript$

x6yk4ghg

x6yk4ghg4#

why were they removed though? serviceWorkers are great for initial caching and performance of the app, even if you're not developing a PWA

4c8rllxm

4c8rllxm5#

我已经运行了npx create-react-app命令两次,但在/src目录下两次都找不到serviceWorker.js文件。所以当我尝试从'./serviceWorker'导入* as serviceWorker时,我得到了一个模块未找到的错误。
对于TS:npx create-react-app my-app --template cra-template-pwa-typescript
这必须是文档的一部分:https://create-react-app.dev/docs/getting-started

8ljdwjyq

8ljdwjyq6#

以下是文本内容的翻译结果:

@khaledosman 这里有一篇关于为什么的文章 - #2398

相关问题