MAC平台create-react-app使用问题(command not found)
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模块

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

解决方法:
通过查阅资料与分析,找到了问题的关键,那么接下来就是如何解决了。我通过在/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无法在终端全局使用的问题。上述问题针对的是MAC平台,window平台并为测试,解决方法应该相似。
MAC平台create-react-app使用问题(command not found)的更多相关文章
- 使用create react app教程
This project was bootstrapped with Create React App. Below you will find some information on how to ...
- 深入 Create React App 核心概念
本文差点难产而死.因为总结的过程中,多次怀疑本文是对官方文档的直接翻译和简单诺列:同时官方文档很全面,全范围的介绍无疑加深了写作的心智负担.但在最终的梳理中,发现走出了一条与众不同的路,于是坚持分享出 ...
- tap news:week5 0.0 create react app
参考https://blog.csdn.net/qtfying/article/details/78665664 先创建文件夹 安装create react app 这个脚手架(facebook官方提 ...
- 如何扩展 Create React App 的 Webpack 配置
如何扩展 Create React App 的 Webpack 配置 原文地址https://zhaozhiming.github.io/blog/2018/01/08/create-react-a ...
- 在 .NET Core 5 中集成 Create React app
翻译自 Camilo Reyes 2021年2月22日的文章 <Integrate Create React app with .NET Core 5> [1] Camilo Reyes ...
- Create React App
Facebook开源了React前端框架(MIT Licence),也同时提供了React脚手架 - create-react-app. create-react-app遵循约定优于配置(Coc)的原 ...
- Create React App 安装less 报错
执行npm run eject 暴露模块 安装 npm i less less-loader -D 1.打开 react app 的 webpack.config.js const sassRege ...
- [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 ...
- [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 ...
- create react app 项目部署在Spring(Tomcat)项目中
网上看了许多,大多数都是nginx做成静态项目,但是这样局限性太多,与Web项目相比许多服务端想做的验证都很麻烦,于是开始了艰难的探索之路,终于在不经意间试出来了,一把辛酸... 正常的打包就不说了. ...
随机推荐
- [LeetCode] Find Minimum in Rotated Sorted Array 二分搜索
Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 migh ...
- glRectf(-0.5f, -0.5f, 0.5f, 0.5f)
http://bbs.csdn.net/topics/370049656 x向右,y向上时OPENGL坐标系,z向屏幕外表示正方向(-0.5,-0.5)是左下角坐标,(0.5,0.5)是右上角坐标,, ...
- usb 2.0 operation mode
一般來說 USB 的通訊結構有如 Server/Client,以 PC 上的情形為例,位於主機上的 USB 裝置稱為『USB Host』,我們可以在上面外接上數個裝置(與 USB Host 相連的裝置 ...
- hdu 1595(最短路变形好题)
find the longest of the shortest Time Limit: 1000/5000 MS (Java/Others) Memory Limit: 32768/32768 ...
- AC日记——3的幂的和 51nod 1013
3的幂的和 思路: 矩阵快速幂: sn-1 3 1 sn * = 1 0 1 1 来,上代码: #include <cstdio> ...
- Codeforces Gym101473 F.Triangles-前缀和 (2013-2014 ACM-ICPC Brazil Subregional Programming Contest)
前缀和. 代码: 1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include< ...
- centos7下使用wget命令安装mysql
1.首先安装wget命令: yum -y install wget 2.下载mysql wget http://repo.mysql.com/mysql-community-release-el7- ...
- js判断是否是PC,IOS,Android客户端
写在前面 在项目中使用html5,需要针对不同的客户端浏览器有不一样的处理方式,这就需要对请求中的useragent进行分析,并进行处理. 一个例子 <%@ Page Language=&quo ...
- 翻译BonoboService官网的安装教程
This page covers simple Bonobo Git Server installation. Be sure to check prerequisites page before i ...
- Dcokerfile 参考
Dcokerfile 包含了所有用来组装image的命令.通过docker build来自动创建image. 用法 需要指定本地路径作为上下文目录,路径是本地系统的目录.而docker build ...