The term '' is not recognized as the name of a cmdlet, function, script file - flutter

I am pretty new to coding and am having this issue, can't understand how to fix it, I have seen similar questions asked but, I just cant understand the majority of them. I've tried adding
the path several times, have even reinstalled Vscode it just doesn't seem to resolve.
The code I've Written::
import 'dart:io';
void main() {
print("Enter your name");
var name = stdin.readLineSync();
print("The name is $name");
}
The Error I am Getting is:
Jack : The term 'Jack' 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.
At line:1 char:1
+ Jack
+ ~~~~
+ CategoryInfo : ObjectNotFound: (Jack:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I have tried:
1:Setting the Paths again
2:Reinstall vs code.
Any kind of information will really help, I can't really progress anymore because of this.

How are you running your program? When I write a program with your exact code, it works.
You have written a command line script in Dart and thus need to run it as such. For example, if you saved your program in the file my_app.dart, then from the command line you could run dart my_app.dart and it'll run your script.
Another way to run it is to create a dart console app and run it using dart run as outlined here: https://dart.dev/tutorials/server/get-started. This would be my recommendation and if you follow the guide I think you'll be able to figure it out, but to quickly confirm your code works you can do the first suggestion.

Related

Windows 10 powershell 'node' not recognized as the name of a cmdlet, function, script file, or operable program

PS C:\Users\DELL> node (OR) gcc --version (OR) g++ --version
node: The term 'node' 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.
At line:1 char:1
node
+ CategoryInfo : ObjectNotFound: (node:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I m having a problem with my Windows 10 Powershell, whenever I tried to get run code of (node/c++/c) via VS code I am getting an error in PowerShell, I have tried restarting my laptop also tried Restarting PowerShell and edited environment paths still I am having the same error I think my Powershell Files got corrupted! please help me I am new to Stackoverflow and A student of B.Sc.IT so my vs code editor for learning purposes is also dependent on Powershell I get totally stuck !! , Thanks in advance!
Due to Posting answer ban I m writing here hope it helps the community
Actually, I have Tried the Following ways to solve this issue on windows 10~
System Restore
Powershell Restart
Powershell Files Replace (with other window system's files in Program files..etc)
Restart PC after troubleshooting
Environment path change
but didn't anything work...
But finally after windows 11 upgrade its automatically solved my issue
I recommend you to install certain things(Apps, software, etc..)
from the official Trusted website and do not tamper with system files
unless necessary also avoid using Crack versions and multiple .NET
frameworks and installers on the same system unless necessary use only
1 INSTALLER OF .NET VISUAL STUDIO latest in my case I think it was the
problem...!!
You have to add node to your PATH. Go to System->Environment Variables->System Variables. Edit the "Path" variable and add C:\Program Files\nodejs.

PowerShell 5 class handling in older versions

I've been trying to search solutions on this one, but I'm coming up blank. I have a small dilemma with a script I've written for PowerShell 5 or higher as it's using classes for it's functionality.
I had added the following to the start of the script hoping it would bail out gracefully on older versions and throw an exit code I can use
If ($((Get-Host).Version.Major) -lt 5)
{
$host.UI.WriteErrorLine('PowerShell Version 5 is required.')
[Environment]::Exit(12345)
}
However, it seems my intended purpose of the above fails because older versions of PowerShell seem to read the whole script and throw the following because it can't interpret the class.
class : The 'class' keyword is not supported in this version of the language.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : ReservedKeywordNotAllowed
Outside of writing a second sort of a wrapper script to handle checking the PowerShell version and then execute the script I've written, is anyone aware of any way to handle this within the single script?

'testcafe' is not recognized as the name of a cmdlet, function, script file, or operable program

I'm trying to run testcafe chrome tests/ -e to execute my test but it throws an error saying
"testcafe: The term 'testcafe' 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.
At line:1 char:1
+ testcafe chrome tests/ -e
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (testcafe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException"
added testcafe locally to project
I'm using Visual Studio Code as IDE and PowerShell terminal for executing commands
Locally installed packages are not automatically added to the search path. Modern npm has npx command.
npx testcafe chrome tests/ -e
should do what you need.
Alternatively you can add your command to npm scripts section as suggested in the documentation.
Take a look at this question: How to use package installed locally in node_modules? for the full discussion.

I can't compile Java files after Windows update! (PowerShell replaced Command Prompt.)

I can't compile any Java programs after PowerShell replaced the Command Prompt in the file menu during a Windows update. I tried using the same SET PATH command that I used with the Command Prompt (set path = c:\"Program Files"\Java\jdk1.8.0_102\bin). The java command worked, but javac was not recognized.
After learning how to access the Command Prompt (type "CMD" in the search box in the bottom left corner), I assumed everything would work like normal - but I was mistaken. The javac command SEEMED to work. It flagged errors when I first tried to compile. After fixing the errors, I thought I had an error free compile. It was when I tried to run my "newly compiled" program that I noticed that my new changes were not showing! I discovered that - in spite of it seeming to compile - no new CLASS files were being created. (It was the old CLASS files that were being run.)
I was then advised to make sure I was the administrator. I did - with PowerShell and the Command Prompt - but it made no difference.
I tried reinstalling Java - but that made no difference either.
Here is what happens when I compile as administrator from the command prompt:
C:\Users\penny\Java>Set Path=C:\"Program Files"\Java\jdk1.8.0_131\bin
C:\Users\penny\Java>javac FoodCount.java
C:\Users\penny\Java>java FoodCount
Error: Could not find or load main class FoodCount
It compiles (or seems to), but no class file is created. And, yes, the javac.exe file IS in the bin file:
C:\Program Files\Java\jdk1.8.0_131\bin>dir javac.exe
Volume in drive C is Windows
Volume Serial Number is 7040-4F22
Directory of C:\Program Files\Java\jdk1.8.0_131\bin
07/12/2017 11:48 PM 15,904 javac.exe
1 File(s) 15,904 bytes
0 Dir(s) 838,527,008,768 bytes free
This is what happened when I used a suggestion from one of the comments for PowerShell. (This was before I reinstalled Java, so the version is a little different. After reinstalling, the result was exactly the same.)
PS C:\Users\penny\Java> $env:PATH += ';c:\Program
Files\Java\jdk1.8.0_102\bin'
PS C:\Users\penny\Java> javac FoodCount.java
javac : The term 'javac' 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.
At line:1 char:1
+ javac FoodCount.java
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (javac:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\penny\Java>
To sum up, I seem to be able to compile with javac.exe from the command prompt, but no new class file can be found in my directory afterwards. I cannot get PowerShell to recognize javac.exe at all.
Can anyone tell me what is going on? I think there must be something going on with the permissions, but being administrator doesn't seem to be enough.
I think Windows fixed this "bug" with another automatic update/patch!
When I tried compiling from the command prompt today, it worked! A class file was saved and I was able to run it. Yesterday, the compiler (javac.exe) seemed to work from the command prompt, but no new class file was created. I don't know why it would behave differently today - unless a Windows update fixed the problem.
I still can't get javac.exe to run in PowerShell, but I don't know what I am doing there.
If anyone else has this problem, my advice is PATIENCE. If you wait, it may go away!

Powershell Function Not Recognised

I've been putting my first powershell scripts together for the last couple of hours and I keep seeing an error that I can't seem to get to the bottom of.
I'm using the Powershell ISE tool to write and run the scripts.
To see if its something in my script I've created a super simple test script and I'm seeing the same problem. The entire test script is:
Test;
function Test
{
New-Item C:\Users\jgreen\Desktop\jammer\ -type directory
}
When I hit the Run Script button the error produced is:
Test : The term 'Test' 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.
If I simply hit the Run Script button again, it work and does the job. I simply do not understand what is wrong. I simply don't get it. Is there a problem with my script or not?
Why would a script that works bomb out the first time after opening the script in PS ISE?
You are calling the function before it is defined. The reason it works the second time, is a result of the first run. When it is ran the first time it's defining the function, so when you run the script the second time it knows what the function is.
You need to declare your function before you invoke it. It works the second time because then it's been declared. Think of how this would work if you were just at a powershell command line and you typed: "Test;" What would you expect to happen?