Create-react-app返回“找不到模块'rxjs'". [英] Create-react-app returns "Cannot find module 'rxjs'"
问题描述
我刚刚在新机器上安装了NodeJS和NPM.我在所有现有项目中添加了 rxjs
包,以使其正常启动.但是,当我运行 create-react-app
时-全局使用npm或npx-我收到错误:找不到模块'rxjs'.似乎 rxjs
是某种事物的新依赖项(考虑到它也会影响旧项目).
I've just installed NodeJS and NPM in a new machine. I added rxjs
package in all my existing projects in order to make then start properly. However, when I run create-react-app
- using npm globally or npx - I receive "Error: Cannot find module 'rxjs'
". Seems like rxjs
is a new dependency of something (considering it's affecting old projects too).
我已经将Node版本更改为8、10和12.重新安装了NPM,将CRA版本更改为2.x.x,问题仍然存在.
I have already changed Node version to 8, 10 and 12. Reinstalled NPM, changed CRA version to 2.x.x and the trouble persists.
如何在没有此问题的情况下使用CRA?
How can I use CRA without this problem?
推荐答案
正如原始海报在评论中所述,解决方法可能是清除缓存.
As mentioned by the Original Poster in the comments, the fix could be to clear your cache.
npm缓存清理--force
如果仍然无法执行,则可以按照以下步骤安装并尝试使用Yarn:
If this still doesn't work, you can follow the steps below to install and try with Yarn:
如果 npx create-react-app my-app
和 npm init react-app my-app
都不适合您,请尝试使用Yarn看看效果如何.
If neither npx create-react-app my-app
and npm init react-app my-app
are working for you, try Yarn to see how it goes.
我曾经使用CRA在Windows,Ubuntu,Mint和macOS上进行过多个项目,但从未明确安装rxjs,也没有要求我这样做.这使我认为,这个问题几乎可以肯定是由 you 引起的,而不是CRA的错误.我认为您已经在Github上搜索了他们的问题.
I have used CRA is multiple projects on Windows, Ubuntu, Mint and macOS and have never explicitly installed rxjs, nor have I been asked for it. This leads me to think that this problem is almost certainly caused by sth local to you rather than sth wrong with CRA. I assume that you have searched through their issues on Github.
尝试使用纱线打开一个新的终端(Linux和macOS)或命令行(Windows)会话,将其cd到您的documents文件夹或其他合适的文件夹.然后运行:
Try it with Yarn Open a new terminal (linux and macOS) or command line (Windows) session cd'd to your documents folder or suitable alternative. Then run:
macOS
酿造纱线
yarn create react-app my-app
Windows(含Chocolatey)
Windows (with Chocolatey)
choco install yarn
yarn create react-app my-app
Ubuntu
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg |sudo apt键添加-
echo"deb https://dl.yarnpkg.com/debian/stable main" |sudo tee/etc/apt/sources.list.d/yarn.list
sudo apt-get update&&sudo apt-get install yarn
yarn create react-app my-app
这篇关于Create-react-app返回“找不到模块'rxjs'".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!