the command - 'npx create-react-app myapp' does not work - javascript

the following command throws the following error
command = npx create-react-app my-app
error =
'"node"' is not recognized as an internal or external command,
operable program or batch file.
before you say create node as an environment variable - it has been created,
node works perfectly fine, npm works perfectly fine - just calling npx raises this issue
any idea why?

fixed the issue by running the command on command prompt and not using hyper terminal
think it has issues running maybe windows based commands on linux

Related

Stripe is not recognized by the terminal in VS CODE

Upon running 'stripe listen' command in terminal in VS Code, it throws an issue :-
The term 'stripe' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that
the path is correct and try again.
Can anybody help me in resolving this?
I have already configured Stripe-CLI for my project using command prompt but it is not working in the terminal of vs code.
You can restart your vscode and then try running your command, if it is running in command prompt outside of vscode. VScode terminal uses available system CLIs like command prompt,powershell & others, so whatever is running outside of vscode terminal, should run in vscode terminal as well.
If your command is not running outside of vscode as well, you can check the PATH variable in your system environment variables (search for environment variables in start menu, assuming Windows OS), whether it contains the path to the folder containing stripe executable file or not. You can add the path if it is not present, then restart your terminals/vscode and try running your command.

bin is not recognized as an internal or external command. npm script

I'm new to node/npm and having an issue trying to start an npm script.
When I try to run a basic script like the one belown, it gives me the error "bin is not recognized as an internal or external command". I think i have had already run succesfully some previous script I made so I don't know if wether my npm is broken or if I did something wrong.
#! node
const app = require('../lib/app')
const config = {
port: 8080
}
app.listen(config.port, () => {
console.log(`Chat is waiting for you at http://localhost:${config.port}`)
})
Screenshot bin error
I have already tried uninstal - reinstall it.
I also checked this post: npm bin command - not recognized as an internal or external command and tried to run npm install -g unsucessfully.
I'm on Windows.
Nevermind.
I just understand what happend. The code was inspired from a Linux user which had the "! env node" on the first line.
I'm on Windows so I removed it but as a result, the script was just trying to run "bin/start" instead of "node bin/start".
Ridiculous error but well, at least i've learned something

expo-cli is installed correctly but run with some errors

I installed expo-cli globally on my machine to start working with react-native, the files of expo are located in the C:\\users\username\node_modules. Despite of installing it globally, windows command line (cmd) doesn't recognize the command expo.
To make the expo command global, i added the path C:\Users\username\node_modules\.bin to environment variables, so the problem of using expo command is solved, i can use it to create a simple react-native application.
When i try to run the application using:
expo start --web
i get the following error:
D:\Testing\myapp>expo start --web
Starting project at D:\Testing\myapp
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Please help me to fix it.
This is a strange error. ENOENT means file not found and spawn cmd means it's trying to run something. One possible fix I found is, editting your state.json file in the location HOMEPATH\.expo\state.json.
Add "openDevToolsAtStartup": false above the PATH line.
Hope this works for you.
Note: If you're using Windows 10, your state.json file will be in C:\Users\your-username\.expo\state.json

Issue related to running of New React App

I installed Nodejs(v 10.16.0 LTS) and then using Windows Powershell I run following commands
npx create-react-app my-app
cd my-app
npm start
The actual problem I am facing is that if PowerShell window is opened in the background, then my code works properly. But when I close PowerShell and reload Browser Tab, the error occurs which say
This site can’t be reached
localhost refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall.
Kindly help me to figure out this issue. Thanks
When you close PowerShell window you terminate your React app as well, it has to stay opened. Running npm start kicks off local server with your app running. If you want to have possibility to have application running with terminal closed you can use libs like https://www.npmjs.com/package/forever, but I do not recommend that- it's easy to forget you have one app instance running already :)
When you run the command npm start, this is the expected behaviour. This command spawns a new npm instance in the directory from where you have executed it and directs it to start a server. The catch here is that the server runs as an attached process with PowerShell, by default and it is bound to terminate once you close the PowerShell window.
To manually detach a process from the terminal, we use an & after the command on a UNIX-based system (Linux, MacOS etc.) something like npm start &.In case of PowerShell, you can make use of a built-in function called Start-Process like this -
Start-Process -NoNewWindow npm start
If you'd like to read more about it, you can refer a blog post here - https://ariefbayu.xyz/run-background-command-in-powershell-8ea86436684e

Create-react-app unable to open IDE when error occurs

I am using create-react-app and everything is working as expected. However I would like that when an error occurs it automatically opens the file in question.
I have set up the .env.local file as suggested.
BROWSER=none
REACT_EDITOR=phpstorm
Error
Note that the development build is not optimized.
To create a production build, use npm run build.
Could not open persistStore.js in the editor.
The editor process exited with an error: spawn phpstorm ENOENT.
To set up the editor integration, add something like REACT_EDITOR=atom to the .env.local file in your project folder and restart the development server.
Maybe this is an error with PhpStorm rather than RCA?

Categories

Resources