You are able to apply the following solution:

$ npm config set prefix /usr/local
$ sudo npm install -g create-react-app
$ create-react-app my-app

 

 

MAC平台create-react-app使用问题(command not found)

标签(空格分隔): React


开始前的BB:作为一位刚入前端的小白,为了自学前端买了些书籍来看,半年后。以为已修成正果,可大杀四方。然而却发现原来人外有人,天外有天,自己依旧是原来的那个小白。。。于是乎打算再次修炼,谁成想第一步就遇见了坑。。。

华丽的分割线


问题描述:

今天在学习React过程中首先便是进行环境的搭建(环境搭建文章),浏览了上述链接文章后发现有两种方式可以搭建React环境,看着第一种比较简单于是乎便打算使用第一种进行搭建。可是谁想一来就出现了问题:

```shell

create-react-app hello

```

执行上述代码后返回create-react-app: command not found报错,意思是不存在该命令。

思考过程:

第一眼我认为可能是没有安装到全局下吧,于是我先删除了,再通过

```shell

npm install -g create-react-app

```

进行重装,本以为是此问题,结果依旧异常。。。

通过查阅资料与看npm文档后发现,npm install -g 命令在默认配置下是将模块安装在/usr/local/lib目录下,于是乎我去该目录查找是否成功安装了create-react-app模块

 
可以看见是存在create-react-app模块的

那么模块存在会不会是不存在指向模块的索引呢?从而导致命令无法识别。。。

 
啊。。果然是不存在create-react-app命令

解决方法:

通过查阅资料与分析,找到了问题的关键,那么接下来就是如何解决了。我通过在/usr/local/bin/的指令内加入对create-react-app文件的调用以解决问题。

create-react-app文件内部代码:

```shell

#!/usr/bin/env node

require("../lib/node_modules/lib/node_modules/create-react-app");

```

 
添加create-react-app文件
 
create-react-app内部代码段

接下来运行create-react-app测试是否能够正常运行create-react-app模块

 
成功运行create-react-app

通过上述操作成功解决了create-react-app无法在终端全局使用的问题。上述问题针对的是MAC平台,window平台并为测试,解决方法应该相似。

MAC平台create-react-app使用问题(command not found)的更多相关文章

  1. 使用create react app教程

    This project was bootstrapped with Create React App. Below you will find some information on how to ...

  2. 深入 Create React App 核心概念

    本文差点难产而死.因为总结的过程中,多次怀疑本文是对官方文档的直接翻译和简单诺列:同时官方文档很全面,全范围的介绍无疑加深了写作的心智负担.但在最终的梳理中,发现走出了一条与众不同的路,于是坚持分享出 ...

  3. tap news:week5 0.0 create react app

    参考https://blog.csdn.net/qtfying/article/details/78665664 先创建文件夹 安装create react app 这个脚手架(facebook官方提 ...

  4. 如何扩展 Create React App 的 Webpack 配置

    如何扩展 Create React App 的 Webpack 配置  原文地址https://zhaozhiming.github.io/blog/2018/01/08/create-react-a ...

  5. 在 .NET Core 5 中集成 Create React app

    翻译自 Camilo Reyes 2021年2月22日的文章 <Integrate Create React app with .NET Core 5> [1] Camilo Reyes ...

  6. Create React App

    Facebook开源了React前端框架(MIT Licence),也同时提供了React脚手架 - create-react-app. create-react-app遵循约定优于配置(Coc)的原 ...

  7. Create React App 安装less 报错

    执行npm run eject 暴露模块 安装 npm i  less less-loader -D 1.打开 react app 的 webpack.config.js const sassRege ...

  8. [React] Use the Fragment Short Syntax in Create React App 2.0

    create-react-app version 2.0 added a lot of new features. One of the new features is upgrading to Ba ...

  9. [React] {svg, css module, sass} support in Create React App 2.0

    create-react-app version 2.0 added a lot of new features. One of the new features is added the svgr  ...

  10. create react app 项目部署在Spring(Tomcat)项目中

    网上看了许多,大多数都是nginx做成静态项目,但是这样局限性太多,与Web项目相比许多服务端想做的验证都很麻烦,于是开始了艰难的探索之路,终于在不经意间试出来了,一把辛酸... 正常的打包就不说了. ...

随机推荐

  1. hdu 1403 Longest Common Substring 后缀数组 模板题

    题目链接 题意 问两个字符串的最长公共子串. 思路 加一个特殊字符然后拼接起来,求得后缀数组与\(height\)数组.扫描一遍即得答案,注意判断起始点是否分别在两个串内. Code #include ...

  2. 《Linux命令行与shell脚本编程大全 第3版》Linux命令行---50

    以下为阅读<Linux命令行与shell脚本编程大全 第3版>的读书笔记,为了方便记录,特地与书的内容保持同步,特意做成一节一次随笔,特记录如下:

  3. Ubuntu 14.04 x64配置Android 4.4 kitkat编译环境的方法

    Ubuntu 14.04 x64配置Android 4.4 kitkat编译环境的方法跟Ubuntu 12.04 - 13.10 以及jellybean编译环境配置没多大区别, 顺便记录下而已: Ub ...

  4. hdu 2104(判断互素)

    hide handkerchief Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  5. JMeter进行http接口测试

    Jmter工具设计之初是用于做性能测试的,它在实现对各种接口的调用方面已经做的比较成熟,因此,本次直接使用Jmeter工具来完成对Http接口的测试. 一.开发接口测试案例的整体方案: 第一步:我们要 ...

  6. linux svn co 重新迁出

    在linux环境下,使用svn co (即svn checkout) 报svn: Authorization failed错误, 使用svn co svn://localhost/temp.cc /d ...

  7. PHP amqp扩展安装

    1.安装 rabbitmq-c下载地址:https://github.com/alanxz/rabbitmq-c> mkdir build > cd build> cmake -DO ...

  8. 安装xz

    原地址: http://jingyan.baidu.com/album/8cdccae9416720315413cd9e.html 1 获取XZ的安装文件,网络下载xz-5.0.3.tar.bz2安装 ...

  9. 解决unknown import path "golang.org/x/sys/unix": unrecognized import path "golang.org/x/sys"

    问题描述 当我们使用 go get.go install.go mod 等命令时,会自动下载相应的包或依赖包.但由于众所周知的原因,类似于 golang.org/x/... 的包会出现下载失败的情况. ...

  10. 简单便捷的纯PHP网盘程序 Veno File Manager 2.6.3(VFM2)

    体验过很多国外网盘程序,例如:Owncloud.Bedrive.YetiShare.XFilesharing.uCloud.Cloudshare 等等,诸如此类,VFM2与这些臃肿的商用或非商用来的程 ...