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. [LeetCode] Search a 2D Matrix 二分搜索

    Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...

  2. 【asp.net】Win7旗舰版IIS配置

    1.IIS配置流程 win7 iis 的配置不需要插入安装盘,可直接在控制面板中开启该功能,步骤如下: (1)"控制面板"-->"程序和功能"--> ...

  3. 解决Manjaro linux的中文输入

    系统安装完成后, 首先:安装中文输入法:pacman -S fcitx fcitx-libpinyin kcm-fcitx 接着:修改.xprofile 添加内容如下: export GTK2_RC_ ...

  4. C#图解教程学习笔记——方法

    一.字段和本地变量.本地常量字段:隶属于类的变量,即类的成员变量.本地变量:于保存本地的或临时的计算数据,即局部变量.本地常量:必须声明在块内部,声明时必须初始化,声明后不能改变.实例字段与本地变量区 ...

  5. TopCoder SRM 301 Div2 Problem 1000 CorrectingParenthesization(区间DP)

    题意  给定一个长度为偶数的字符串.这个字符串由三种括号组成. 现在要把这个字符串修改为一个符合括号完全匹配的字符串,改变一个括号的代价为$1$,求最小总代价. 区间DP.令$dp[i][j]$为把子 ...

  6. [Python Debug] SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame.

    I Got a SettingWithCopyWarning when I ran the following code: tmp=date[date['date'].isnull().values= ...

  7. 洛谷——P2205 [USACO13JAN]画栅栏Painting the Fence

    题目描述 Farmer John has devised a brilliant method to paint the long fence next to his barn (think of t ...

  8. Arduino可穿戴教程认识ArduinoIDE

    Arduino可穿戴教程认识ArduinoIDE 认识ArduinoIDE Arduino IDE在Windows和Linux平台下除了启动方式之外,其他的使用方式基本是一致的.下面简单介绍一下常用的 ...

  9. Linux运维:CentOS6和7的区别

    Liunx笔记:CentOS6和CentOS7的区别 路飞学城运维人员 在线流程图软件 Ago linux运维群: 93324526 笔者QQ:578843228 常用安装包下载 yum instal ...

  10. Java中Properties配置文件读取

    以下实践的是Properties配置文件的基本操作方法.像spring使用xml做依赖注入时,这个配置文件起到非常实用的作用. 一.格式规范 参考wiki百科的格式简介:https://zh.wiki ...