简体   繁体   English

Create-react-app返回“无法找到模块'rxjs'”

[英]Create-react-app returns “Cannot find module 'rxjs'”

I've just installed NodeJS and NPM in a new machine. 我刚刚在一台新机器上安装了NodeJS和NPM。 I added rxjs package in all my existing projects in order to make then start properly. 我在所有现有项目中添加了rxjs包,以便正确启动。 However, when I run create-react-app - using npm globally or npx - I receive "Error: Cannot find module 'rxjs' ". 但是,当我运行create-react-app - 使用npm global或npx - 我收到“错误:无法找到模块'rxjs'”。 Seems like rxjs is a new dependency of something (considering it's affecting old projects too). 似乎rxjs是某种东西的新依赖(考虑到它也影响旧项目)。

I have already changed Node version to 8, 10 and 12. Reinstalled NPM, changed CRA version to 2.xx and the trouble persists. 我已经将Node版本更改为8,10和12.重新安装NPM,将CRA版本更改为2.xx并且问题仍然存在。

How can I use CRA without this problem? 如何在没有此问题的情况下使用CRA?

As mentioned by the Original Poster in the comments, the fix could be to clear your cache. 正如评论中的原始海报所述,修复可能是清除缓存。

npm cache clean --force

If this still doesn't work, you can follow the steps below to install and try with Yarn: 如果这仍然不起作用,您可以按照以下步骤安装并尝试使用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. 如果npx create-react-app my-appnpm init react-app my-app都不适合你,试试Yarn看看它是怎么回事。

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. 我用过CRA是Windows,Ubuntu,Mint和macOS上的多个项目,从未明确安装过rxjs,也没有被要求过。 This leads me to think that this problem is almost certainly caused by sth local to you rather than sth wrong with CRA. 这让我觉得这个问题几乎肯定是由本地引起的,而不是CRA的错误。 I assume that you have searched through their issues on Github. 我假设您已经在Github上搜索了他们的问题。

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. 尝试使用Yarn打开一个新的终端(linux和macOS)或命令行(Windows)会话cd'd到您的文档文件夹或合适的替代方案。 Then run: 然后运行:

macOS 苹果系统

brew install yarn

yarn create react-app my-app

Windows (with Chocolatey) Windows(带巧克力)

choco install yarn

yarn create react-app my-app

Ubuntu Ubuntu的

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Moment JS 创建 React-App:找不到模块“./locale” - Create-React-App with Moment JS: Cannot find module “./locale” create-react-app 返回错误:执行时找不到模块“react-scripts/scripts/init.js” - create-react-app returns an Error: Cannot find module 'react-scripts/scripts/init.js' when executed 错误:找不到模块“rxjs” - 创建 React 应用程序 - Error: Cannot find module 'rxjs' - Create React App create-react-app npm start错误:找不到模块'@ webassemblyjs / ast' - create-react-app npm start Error: Cannot find module '@webassemblyjs/ast' npx create-react-app 失败并出现错误“找不到模块块流 - npx create-react-app fails with error "cannot find module block-stream create-react-app 后无法启动项目:错误:找不到模块“C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js” - Unable to start project after create-react-app: Error: Cannot find module 'C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js' npx create-react-app 命令不起作用,而是返回 ES 模块错误 - npx create-react-app command does not work, returns ES module error instead 无法使用 create-react-app 创建新的 React 应用程序 - Cannot create a new React application with create-react-app 在Heroku上获取请求会返回create-react-app默认页面? - Get request on Heroku returns create-react-app default page? npx create-react-app 命令返回错误 - npx create-react-app command returns error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM