zsh: command not found: create-react-app on ubuntu 17.04 - reactjs

I can't get react work on Ubuntu, I just get command not found, can't fix it.
npm install -g create-react-app
/home/name/.npm-global/bin/create-react-app -> /home/name/.npm-global/lib/node_modules/create-react-app/index.js
+ create-react-app#1.4.0
updated 1 package in 4.61s
after that I enter:
create-react-app app
zsh: command not found: create-react-app
.zshrc file
export PATH=$HOME/.node_modules_global/bin:$PATH
I understand that obviously is in path problem, but I can't figure it out, I have some experience with Linux, but I just can't fix this and to get react work.
Thanks.
Ubuntu 17.04
node v8.4.0
npm v5.3.0
Thank you.

Seems to me that you need to add ~/.npm-global/bin/ to your $PATH:
export PATH=~/.npm-global/bin/:$HOME/.node_modules_global/bin:$PATH

Related

Couldn't determine repo type for URL: `https://cdn.cocoapods.org/`: Permission denied # rb_sysopen - /Users/admin/.netrc React native

When I am installing pod it shows me this error, I've tried reinstalling cocoapods and an older version of react native just to make sure if it's version issue.
It's solved, it was a permission issue in every file on my MacBook. I used sudo chown -R macbook-name: /yourfilepath. Use this command whenever you faced permission-denied errors.

zsh: command not found: nx

I am trying to create a library in Angular using nx g #nrwl/angular:lib shared but it keep giving me error zsh: command not found: nx. All I did was before just create a angular project.
I try using this: npm install -g nx so maybe it install nx and it works, but I still keep getting the same error.
How can I fix this? I am using Mac.
If any questions or information needed please feel free to leave the comment down below.
sudo npm install -g nx fixed, sudo might be needed...
Try this: Install it globally by below command 100% will work
sudo npm i -g #nrwl/cli
remove -g if you don't want to install globally.
Either you don't have refreshed your zsh paths, which can be fixed by opening a new terminal or type
rehash
in the prompt.
If this doesn't work then nx isn't globally installed on your machine. You have to type
npm run nx [your command] instead of just "nx" to use it, so in your case:
npm run nx -- g #nrwl/angular:lib shared
Sources: https://nx.dev/latest/angular/cli/overview#installing-the-cli
Do we really need to install #nrwl/cli ?
Just installing the nx resolve the issue for me
sudo npm install -g nx#latest
Installing the nrwl cli globally should do the trick, you'll need to enter the super user mode to do it.
sudo npm i -g #nrwl/cli
Alternative solutions can be found on the guide on the Nx Website here
https://nx.dev/l/a/tutorial/01-create-application
Try this:
yarn global add #nrwl/cli

having an issue creating new react app with create-react-app

I am trying to create a new react project, but when I run npx create-react-app tik-tok-clone I get the following error
Creating a new React app in C:\Users\mwars\Documents\GitHub\TikTok-Clone\tik-tok-clone.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
yarn add v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
error postcss#8.1.3: The engine "node" is incompatible with this module. Expected version "^10 || ^12 || >=14". Got "13.12.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Aborting installation.
yarnpkg add --exact react react-dom react-scripts cra-template --cwd C:\Users\mwars\Documents\GitHub\TikTok-Clone\tik-tok-clone has failed.
Deleting generated file... package.json
Deleting generated file... yarn.lock
Deleting tik-tok-clone/ from C:\Users\mwars\Documents\GitHub\TikTok-Clone
Done.
I've been trying to figure it out for a while now and just can't get it to work.
I am was dealing with the same problem and have managed to understand and fix it. I will try to explain it below.
The issue:
error postcss#8.1.3: The engine "node" is incompatible with this module. Expected version "^10 || ^12 || >=14". Got "13.12.0"
This is telling you that the create_react_app module is only compatible with versions 10, 12, or greater than 14 of node and you are using 13.12.0.
The solution
To fix this error you need to either upgrade or downgrade your current version of node.
One way to do this is to use NVM (node version manager) to manage multiple versions of node.
To install it with either Linux or Mac you can use either of the following commands
For Wget, run the following command on the terminal:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
For CURL, run the following:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
You will want to change the version number in the commands to the latest stable version.
Once you have downloaded it successfully restart the terminal or you won't be able to find it. If this fails you may need to reset your computer.
If you have NVM installed running the following should show you the current version of it your using.
nvm --version
You can then use the following command to list available versions of node
nvm ls-remote
Select a compatible version and install it like so
nvm install 14.15.0
Running
node -v
Should show this as your current version if not try
nvm use v14.15.0
You should now have no issues running
npx create-react-app tik-tok-clone
It worked for me after running these commands.
sudo npm cache clean -f //clear you npm cache
sudo npm install -g n install n //(this might take a while)
sudo n stable upgrade //to the current stable version

npm start on new create-react-app build returns ELIFECYCLE error

Made a new react app using create-react-app and now getting the following error in the terminal when running npm start:
> react-scripts start
Attempting to bind to HOST environment variable: x86_64-apple-darwin13.4.0
If this was unintentional, check that you haven't mistakenly set it in your shell.
events.js:167
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND x86_64-apple-darwin13.4.0
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
Emitted 'error' event at:
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1468:12)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! aqi#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the aqi#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/chris/.npm/_logs/2018-12-24T10_07_46_970Z-debug.log
Tried removing the node-module folder and npm install.
type unset HOST in the terminal. It will solve the issue.
I struggled with this exact issue for an entire day. If you do unset HOST, it will solve it, but temporarily. The simple solution to this bug is as follows (this is for Mac, for Window the commands may differ):
Open your bash with the following command: open ~/.bash_profile
Write this down (exactly what it says) all the way down the file once the file opens: HOST="localhost"
After that, save the file and quit (Command + q)
Finally, reload the environment by typing this on the terminal:
source ~/.bash_profile
If you do all the steps correctly, this should resolve the bug.
Mostly the problem occurs when you set a specific hostname instead of regular used one localhost.
On Mac/Linux terminal run hostname, you will receive the specified hostname. If it's something different than localhost refer to your bash profile config file (ie for ZSH it's .zshrc, or for Bash it's .bashrc in your home directory); and if HOST=localhost exists in the profile comment it.
PS: do not forget to restart your terminal to make the change takes effect.
I also struggled with this. Many online solutions only solve the first part. Here I'll provide my approach to fully solve the issue and make npm start work
Understand the issue:
There are 2 parts to the problem. First, you want to set your environmental variable, HOST, to "localhost". You can do it by typing in your terminal (anywhere):
nano ~/.bash_profile
In the bash file, type HOST="localhost" in a new line and type: export HOST. This directs your program to go to this HOST by default
Save change by Ctrl + X, then press Y (Yes), then press Enter
Return to your terminal, run: source ~/.bash_profile to refresh the terminal
Now, your computer has updated its HOST variable to localhost. You can check that by typing: env | grep HOST in the terminal. Grep means to grab that variable in the variable list.
Hopefully that solves the issue fully. If you then encounter: dyld: lazy symbol binding failed.
This simply means there's something wrong with the fsevents. Why? I am not sure, but a sure fix is by deleting the node_modules/fsevent files from my search. A permanent fix is to remove the node modules and re-do the npm install. Make sure that fsevent is version 2.0+!
Hope that helps. This surely took some time to debug!
References:
dyld: lazy symbol binding failed: Symbol not found: _node_module_register
https://medium.com/#choy/fixing-create-react-app-when-npm-fails-to-start-because-your-host-environment-variable-is-being-4c8a9fa0b461
https://medium.com/#youngstone89/setting-up-environment-variables-in-mac-os-28e5941c771c
I was able to fix the similar error by running npm install create-react-app instead of npm install -g create-react-app. Hope it helps.
you should create .env files
https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables#adding-development-environment-variables-in-env
read this Environments in Create React App
https://serverless-stack.com/chapters/environments-in-create-react-app.html
unset HOST
This worked for me, if not, then run the code and give it a reboot
I ran into this issue because I usually had anaconda running as default in the terminal. So my login is not just my computer login account but appending with some string created by conda. (eg xxx#xxx)
However, in order to get the react server up and running normally you will need to have your login as your computer login id. (eg xxx#)
There are two solutions to achieve this.
to run unset HOST, it will get rid of the string at # of your terminal log in id.
to add HOST as env var to your terminal config file. For zsh user (most likely cos mac now run zsh as default in the terminal) You need to add export HOST="localhost" or export HOST="" to ~/.zshrc and run source ~/.zshrc in the terminal to refresh the new zsh config. You can do the same to bash config file by following one of the answers above.
GOOD LUCK.
Attempting to bind to HOST environment variable: x86_64-apple-darwin13.4.0
If this was unintentional, check that you haven't mistakenly set it in your shell.
This issue comes once we write npm start in terminal, to rectify the issue in your terminal before executing the command npm start write unset HOST then write the command npm start it works fine and you can check on localhost://3000

Installing typescript definition manager

Hi I am trying to install the typescript definition manager (TSD) on my Ubuntu 14.04 VM. I am following the '5 minute tutotial' from Angular.
It says to run
npm install -g tsd#^0.6.0
After that I am supposed to run
tsd install angular2 es6-promise rx rx-lite
Anyway, after running the last command Ubuntu simply returns
tsd: command not found
Can anyone help here?
Can you run the npm install -g tsd again, it should output the location where it installs it for you.
In this case that location isn't added to your path variable and you should use a absolute location (or add it to your path).
You should be able to do this in ubuntu by creating a ~/.profile file with
export PATH=$PATH:/path/to/tsd/folder/
The problem in my case seemed to be the nodejs version on my Ubuntu VM. I created a new VM and installed nodejs the following way
cd /usr/local/src
wget http://nodejs.org/dist/v0.12.7/node-v0.12.7.tar.gz
tar -xvzf node-v0.12.7.tar.gz
cd node-v0.12.7
./configure
make
sudo make install
which node
After this I could run
tsd install angular2 es6-promise rx rx-lite
and everything worked as expected. SO I believe updating the my nodejs was the solution. It seems that my old nodejs did not add tsd to the path
Can anyone help here?
Check your node version. Recommend you use latest iojs. It works as shown :

Resources