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. mysql error 1093 解决办法

    mysql> select * from t; +----+ | id | +----+ | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 ...

  2. Django之model F/Q以及多对多操作

    model之F/Q操作 F操作,使用查询条件的值 打个比方吧,有一张表,保存着公司员工的工资,公司普涨工资,如何在model中操作,这就用到了F,首先需要导入此模块: from django.db.m ...

  3. 洛谷——P1125 笨小猴

    P1125 笨小猴 题目描述 笨小猴的词汇量很小,所以每次做英语选择题的时候都很头疼.但是他找到了一种方法,经试验证明,用这种方法去选择选项的时候选对的几率非常大! 这种方法的具体描述如下:假设max ...

  4. 如何在CentOS 7上安装Nginx

    第一步 - 添加Nginx存储库要添加CentOS 7 EPEL仓库,请打开终端并使用以下命令: sudo yum install epel-release第二步 - 安装Nginx现在Nginx存储 ...

  5. Java中final和static关键字总结

    1.final: final关键字可用于类.方法.变量前. final修饰的类不可被继承,例如java.lang.Math就是一个 final类,不可被继承. final修饰变量,在显示初始化后不可改 ...

  6. Linux内核Crash分析

    转载自:http://linux.cn/article-3475-1.html 在工作中经常会遇到一些内核crash的情况,本文就是根据内核出现crash后的打印信息,对其进行了分析,使用的内核版本为 ...

  7. ASIHTTPRequest实现断点续传

    http://blog.csdn.net/daiyelang/article/category/1377418 ASIHTTPRequest可以实现断点续传.网上有一些介绍类似使用:   [reque ...

  8. 【java】Map、Set、List不同数据结构的各种不同循环迭代的效率对比,使用场景

    Map.Set.List不同数据结构的各种不同循环迭代的效率对比,使用场景 引申一个地址:Map迭代的使用keySet和entitySet的效率

  9. ASP.NET MVC Web API 学习笔记---第一个Web API程序【转】

    http://www.cnblogs.com/qingyuan/archive/2012/10/12/2720824.html 1. Web API简单说明 近来很多大型的平台都公开了Web API. ...

  10. Notification(二)——PendingIntent的flag导致数据同样的问题

    MainActivity例如以下: package cc.cu; import android.os.Bundle; import android.view.View; import android. ...