Stripe is not recognized by the terminal in VS CODE - javascript

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.

Related

How to get output of the JS file using VS Code

When I run the code, nothing shows in "Output" tab. I installed nodejs as well as Code runner extension. How to fix this issue?
enter image description here
I want to get the output of my code.
Install Node.js from https://nodejs.org.
open VS Code.
from the file tab at the top, choose open folder.
navigate to your working directory where your project is open.
from the terminal tab at the top, choose new terminal.
in the terminal, write the following command:
node sample_1.js
replace the sample_1.js with your file name
This is the top menu
and this is the terminal:
--
and you don't need a code runner extension, every time you want to run your JavaScript code, write the command
node YOUR_FILE_NAME.js
Otherwise, if you want something to automatically detect the changes you make to your file and automatically run the code when you save the file, you'll need a package like nodemon.
to install nodemon, in the same working directory, open up the terminal and write the following commands:
npm init -y
and then:
npx nodemon sample_1.js
replace the sample_1.js with your file name
Nodemon will keep running in the background and every change you make to any of your files in your working directory will make nodemon reload, and you'll see the changes in the terminal immediately.
I fixed that issue. I installed JavaScript Debugger(Nightly). After that now OUTPUT tab shows output of the js file.
https://marketplace.visualstudio.com/items?itemName=ms-vscode.js-debug-nightly

"'bun' not found" error in Windows with WSL

First, I run this command on my windows machine
$curl https://bun.sh/install | bash
Output of the above first command
Second, I run this command to set this path in the file
$nano ~/.bashrc
Output of the above second command
After setting these variables into the ~/.bashrc file.
I am trying to check the version of Bun which is just installed, with this command :
$bun --version
After running the above command I got this output :
Command 'bun' not found, did you mean:
command 'ben' from deb ben (0.9.0ubuntu2)
command 'bus' from deb atm-tools (1:2.5.1-4)
command 'zun' from deb python3-zunclient (4.0.0-0ubuntu1)
Try: apt install <deb name>
Can anyone please help me to activate Bun smoothly on my windows machine?
I can tell you that I have successfully installed Bun in Ubuntu 20.04 on WSL2. However, note that it will not currently run in WSL1 (from the Unix & Linux Stack). That's not the error you are seeing here, however.
Apologies in advance if this is not the case, but given that you are new here, I'm going to make an assumption that it might be something very basic that is causing the error you are seeing. The output of the first command indicates that Bun was installed properly, so if it's not found, it seems most likely that you missed one crucial step. You also didn't state that you did it, so ...
~/.bashrc is a file that is typically only read when you start Bash. After adding the variables to your ~/.bashrc, to have it actually set the variables in a shell session, you need to either:
source ~/.bashrc`
Or simply start a new shell (exit WSL and restart, or just run another bash inside bash, etc.
Of course, after doing this, you'll still need to be running WSL2, or you'll run into the other error.
Note that, beyond simply creating a project, I have not tested Bun extensively in WSL2. The Fireship-guy on YouTube did mention that he had some challenges in getting it to run under WSL, but I'm not sure what those were.
I've present the same problem.
Context sotware=> I use win 11 and I've download ubuntu
microsoft store
For this, I enable in feactures
windows turn on and off feactures
and clink here these options
For download bun 0.1.8
I've execute this command
curl -fsSL https://bun.sh/install | bash
late, at the console say that i have to put 2 line of code in a file in my case are :
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
When, I tried execute bun --version the console showed that did't find bun.
I restart the windows and it seems to have worked
I found answers in the post https://stackoverflow.com/a/73097326/5072481 add username path to $HOME/ is the point

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

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

'node' is not recognized as an internal command or external, an executable program or a batch file

First of all, I wanted to learn Node.js, I opened my code editor then logged a simple word. but the problem is when I open my terminal I write :
node server.js
but it says :
'node' is not recognized as an internal command
or external, an executable program or a batch file.
I don't know how to fix the problem even in my editor's terminal.
Seems you haven't installed node on your system. Be sure if you have installed node or not.
Just open your terminal and type node
If you don't see a message like this Welcome to Node.js v14.12.0. then check this official download/setup link.
If you're using Ubuntu, then follow this link.
For any other Linux distro, just search Install node on <manjaro>.
Change with your distro name.

How to run javascript with require node modules in local [duplicate]

I am trying to run a hello world program written in javascript in a separate file named hello.js
Currently running windows version of node.js.
The code runs perfectly in console window but how do I reference the path in windows environment.
C:\abc\zyx\hello.js
in Unix I guess it is showing $ node hello.js
I'm absolutely new to Node.js Please correct me if I am doing something wrong.
I tried
> node C:\abc\zyx\hello.js ----didn't work
> C:\abc\zyx\hello.js --didn't work
UPDATE1:
Added node.exe to the folder where hello.js file is sitting.
Added path point to the folder c:\abc\zyx\ and I get an error that says
ReferenceError: hello is not defined
see contents of hello.js
setTimeout(function() {
console.log('World!');
}, 2000);
console.log('Hello');
UPDATE 2:
So far I have tried all these version and none of them seems to work. May be I am doing something completely wrong.
>node hello.js
>$ node hello.js
>node.exe hello.js
>node /hello.js
>node \hello.js
> \node \hello.js
> /node /hello.js
> C:\abc\xyz\node.exe C:\abc\xyz\hello.js
> C:\abc\xyz\node.exe C:/abc/xyz/hello.js
> hello.js
> /hello.js
> \hello.js
>node hello
Refer to my file structure
.
├── hello.js
├── node.exe
└── paths.txt
RESOLVED:
Instead of running node.exe, try running in command prompt with the following option and it worked.
c:\>node c:\abc\hello.js
Hello
World! (after 2 secs)
Here are the exact steps I just took to run the "Hello World" example found at http://nodejs.org/. This is a quick and dirty example. For a permanent installation you'd want to store the executable in a more reasonable place than the root directory and update your PATH to include its location.
Download the Windows executable here: http://nodejs.org/#download
Copy the file to C:\
Create C:\hello.js
Paste in the following content:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
Save the file
Start -> Run... -> cmd
c:
C:>node hello.js
Server running at http://127.0.0.1:1337/
That's it. This was done on Windows XP.
Install the MSI file:
Go to the installed directory C:\Program Files\nodejs from command prompt n
C:\>cd C:\Program Files\nodejs enter..
node helloworld.js
output:
Hello World
You need to make sure that node is in your PATH. To set up your path, this out.
Make sure that the directory that has node.exe is in your PATH. Then you should be able to
run node path_to_js_file.js.
For a good "Hello World" example, check out: http://howtonode.org/hello-node
another simple way
download nodejs to your system
open a notepad write js command "console.log('Hello World');"
save the file as hello.js preferably same location as nodejs
open command prompt navigate to the location where the nodejs is located
c:\program files\nodejs
and run the command from the location like c:\program files\nodejs>node hello.js
in case the js file in another location give the path of file
c:\program files\nodejs>node path\hello.js
I installed node for windows.
There is a node.js command prompt when I search for node.js in windows 7 start menu
If you run this special command prompt, you can node anything in any location without setting up the path or copy node.exe everywhere.
WinXp:
I have created a .bat file
node c:\path\to\file\my_program.js
That just run my_program.bat from Explorer or in cmd window
Go to cmd and type: node "C:\Path\To\File\Sample.js"
Windows/CMD does not know where the node file is located. You can manually type out:
path=%path%;"c:\Program Files\nodejs"
each time you open a new cmd.exe prompte
OR (in Windows 10),
right click on This PC -> properties.
Click on Advanced system settings -> Environment Variables (bottom right).
Select Path and click Edit.
Click new and enter C:\Program Files\nodejs.
Reboot and you should be able to run node from any directory.
Just change file association of .js file to node.exe and you can run directly from explorer.
Right click on the file -> Select "Open with" -> Select "Choose another program"
Check box "Always use this app to open .js file"
Click "More apps" -> "Look for another app in PC"
Navigate to node.js installation directory.(Default C:\Program Files\nodejs\node.exe"
Click "Open" and you can just see cmd flashing
Now you will be able to run any .js files directly just by double clicking.
Note: Adding below code to the end of js file will be useful as it will keep the console open for a keystroke.
console.log('Press any key to exit');
process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.on('data', process.exit.bind(process, 0));
The problem was that you opened the Node.js repl while everyone automatically assumed you were in the command prompt. For what it's worth you can run a javascript file from the repl with the .load command. For example:
.load c:/users/username/documents/script.js
The same command can also be used in the command prompt if you first start node inside the command prompt by entering node with no arguments (assuming node is in PATH).
I find it fascinating that 1)everyone assumed you were in the command prompt rather than repl, 2)no one seems to know about .load, and 3)this has 273 upvotes, proving that a lot of other node.js beginners are similarly confused.
Step For Windows
press the ctrl + r.then type cmd and hit enter.
now command prompt will be open.
after the type cd filepath of file. ex(cd C:\Users\user\Desktop\ )
then hit the enter.
please check if npm installed or not using this command node -v.
then if you installed will get node version.
type the command on command prompt like this node filename.js . example(node app.js)
C:\Users\user\Desktop>node app.js
type node js command prompt in start screen. and use it.
OR
set PATH of node in environment variable.
Install node properly, that's it.
Now open terminal to path where your .js file is.
for example- if Javascript file(fileName.js) is at folder C:\Documents\Project1.
Just go to that folder, type node to check node is enable
then type node fileName.js
Simple! Your work is done!!
c:\> node.exe %CD%\hello.js
%CD% captures the current directory under DOS
For all stuck on how to start!
https://github.com/sethvincent/javascripting
Copy here incase link dies:
Open node.js command prompt
Make directory called javascripting by typing "mkdir javascripting"
Change directory into the javascripting folder by typing "cd javascripting"
Create a file named introduction.js by typing "touch introduction.js" OR FOR WINDOWS: "NUL > introduction.js"
Open the file and type some javascript e.g. "Console.log('hello');"
Save the file and check it runs by typing "javascripting verify introduction.js"
All you have to do is right click the .js file on Windows and press "Open with Command Prompt"
OR
Open cmd, copy the path to the folder containing your script, and run the command "cd [paste text here]". Then do "node example.js"
I had such problem for windows. And I decided it so:
startApp.cmd:
#set JAVA_HOME=C:\jdk160_24
#set PATH=%JAVA_HOME%/bin;%PATH%
#cd /D C:\app\
#start /b C:\WINDOWS\system32\cscript.exe
C:\app\start.js
and saved it cmd file in dir C:\scripts
next file is runApp.bat:
C:\scripts\startApp.cmd

Categories

Resources