Running NPX Create React App from a Bash Script - bash

I am trying to create a bash script that runs npx create-react-app my-app.
My Current Script:
cd /Users/theuser/Development
/usr/local/bin/npx create-react-app my-app
I have tried simply calling npx command and also pointing directly to binary but when the script is executed (from an Alfred Workflow) I do not see a React App created.
If I run the /usr/local/bin/npx create-react-app my-app from terminal then I do see the React App Created.

I found that temporarily setting the PATH fixed the issue, attaching a debugger to my script execution showed that node could not be found...
PATH=/usr/local/bin npx create-react-app application

Related

We no longer support global installation of Create React App

can anyone explain what is this as far as I know I had installed sanity and nodemon globally they are also not allowed ?
PS C:\Users\Rupesh Gupta\Documents\GitHub\PinShare\pinshare_frontend> npx create-react-app#next --scripts-version=#next --template=cra-template#next ./
You are running create-react-app 5.0.0-next.60+6a3315b7, which is behind the latest release (5.0.0).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
npm uninstall -g create-react-app
yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
PS C:\Users\Rupesh Gupta\Documents\GitHub\PinShare\pinshare_frontend>
I had the same issue on that project. I solved it by running
npx clear-npx-cache
and then
npx create-react-app#latest ./ --use-npm
"./" if you're already in the folder you wanted to CRA into, or "your-project-name" if you're not.

Cannot read property 'compilation' of undefined when running NPM script

Recently we have been tasked to move from YARN to NPM in a project that was developed a few years ago. The conversion was pretty smooth. We have noticed the following error when trying to run this script:
"start-frontend": "cd frontend && elm-app start",
The following error is returned when 'npm run start-frontend' is executed:
digital_bill#1.0.0 start-frontend /Users/xxxx/workspace/kittyworks-frontend
cd frontend && elm-app start
Failed to compile.
Cannot read property 'compilation' of undefined
There is a frontend directory as a child directory to where NPM is being run (location of package.json). If I execute these commands in terminal the command 'elm-app start' works without error once we cd into frontend.
This is running on a MAC (Catalina) with NPM 6.1.8. ELM is 0.18.
Not sure what is happening here.

about 'zsh react-native command not found' AFTER SETTING PATH

Some time ago, I had the command not found error when running expo, so I set path at ~/.bash_profile and so, after running source ~/.bash_profile, now I can call expo without problems.
Today, I tried running react-native link and the following error appeared:
zsh: react-native command not found
What else could I be doing wrong?
Maybe you don't have react native cli installed globally, which is good as it's not needed.
Check in the project directory if react-native is installed
so ./node_modules/react-native/ should exist and has something inside.
If so, you don't need to run react-native directly; try running through npx react-native or npm script.
If not, make sure you have react-native in package.json dependencies section, and run npm install to pull the react-native library folder.

Yarn problem with Windows when creating React app

I'm trying to use Yarn to create a react app (I named it sagas2) and I'm getting this error.
I think it is because my Windows username has a space (Name lastname).
Yes it is issue because of having space in your path. It is a know issue if your are using npx as mentioned in https://github.com/facebook/create-react-app/issues/6512
Instead you can try below as a work around:
npm install -g create-react-app
create-react-app my-app

INFO Waiting for connectivity with npm...Error in Setting up development environment for MoodleMobile_2

I have followed the steps for setting the development environment for moodle mobile 2.
https://docs.moodle.org/dev/Setting_up_your_development_environment_for_Moodle_Mobile_2
Command:
npm run setup
Which executes successfully, but
ionic serve --google chrome
.. hangs on!
[INFO]Waiting for connectivity with npm...
I also tried:
npx gulp watch & npx ionic-app-scripts serve -b --devapp --address=0.0.0.0
As given in above document (Troubleshooting section) but now hangs:
Please help me out..
If you use PowerShell, open 2 PowerShells, go to your MoodleApp folder in each PowerShell and then:
In the 1st one, run
npx gulp watch
In the 2nd one, run
npx ionic-app-scripts serve -b --devapp --address=0.0.0.0
When dev server is running and lint finished, you can see Moodle by opening http://localhost:8100/ in Chromium/Chrome browser.

Resources