I am trying the petshop client generation example on github and autorest just exits without creating anything or throwing any errors. Autorest behaves like I did not pass any arguments. Attached is a screenshot of my powershell execution.
Try executing your same command but add --verbose at the end to tell autorest to print out any errors.
I was experiencing the same problem and what worked for me was creating the following readme.yml file and simply running the command
autorest readme.yml
With those two things (readme.yml and the command) I was able to generate the code in csharp without any issues.
Image of Readme.yml for csharp code generation:
For me what finally worked was:
Install the latest Node from https://nodejs.org/
Go to C:\Users\%userprofile%\AppData\Roaming\npm and delete the 2 autorest files there if you have them.
Open a Command Prompt (type cmd in the address of any Windows folder)
In the Command Prompt type this command:
npm cache clean -f
Now, also in the same Command Prompt, type this command:
npm install autorest -g
You should now be able to generate your client.
This answer on GitHub repo of Autorest, suggest that you execute
autorest --reset
after updating. It removes older plugins of Autorest. I had the same problem (without updating Autorest) and it has solved after that.
Related
TL;DR
I cannot execute commands such as tsc unless I include npx before it (e.g npx tsc). How can I fix this?
The title is a bad explanation of the problem I have.
Say I have installed an npm package with a CLI with it (typescript in this example). And the CLI is used like
tsc <filename> or just tsc. But whenever I try to do it like that, I get an error like
'tsc' is not recognized as an internal or external command,
operable program or batch file.
But... when I do
npx tsc
then it works!
So whats the problem?
The problem with doing npx tsc is because
npx is slow at executing commands
its annoying having to type npx and the front of every command.
And the thing is, this was originally not a problem with WSL.
Why dont you just use WSL?
I have always had problems with WSL (primarily permission issues due to security reasons) and so I uninstalled WSL and just used command prompt. I would have perferred using WSL but it was simply not an option.
Other Info:
I am using Windows command prompt.
I have installed the packages globally
So is there a way to just execute commands that way or is it Command prompts fault?
! this only works for Windows !
Ok, so I came across this post and thankfully, the first answer there was the solution!
Just add %USERPROFILE%\AppData\Roaming\npm to the path variable in system variables!
To access the system variables, press the Windows key, type Environment variables and click on Environment variables at the bottom of the window. The path variable can be found under User variables for (profile name).
Alright, I have a extremelly newbie question to ask. How do I run the code I have on my visual estudio code?
I see my files with the code inside (the code I took it from a github public tutorial) now, in one part of the tutorial it says "let's check how it works" and types the command npm run install and then inside of the IDE terminal the code starts to run.
Now, unfortunately, the tutorial never mentions in what file we are (is it a new file) or if it's just the IDE main terminal calling up the program main function.
So, what I tried to do was to put the same line of code on the terminal of visual estudio code, and I get this error:
'npm' is not recognized as internal or external command, operable program or batch file.
Now, what I am thinking is that I need to type npm install in a specific window, but on the tutorial is just stated "let's take a look at the program"
sorry, I feel as I am asking were do I put the keys to enter my house, it is an extremelly simple/dumb question, but I guess these little details are what make newbies like me get lost in the most simple tasks.
I also tried the menu on visual studio code, click on terminal and then on run task and then select one of the options that are on the default -install or npm run start. Same error.
You need to install npm globally. If you are using Windows you will probably need to add it in environment variables also. Check also if you have install Node.js (when you install Node.js, npm will be automatically installed).
You can check this Docs: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
Once you do that you can use npm as a command in your terminal.
I am no longer able to run node from the git bash terminal. It works from Git CMD and the standard windows CLI. If I try to run a file (e.g. node index.js) or even just start node via node, I go back to the input prompt except now I can't see any of my character inputs.
This is not a result of PATH not being set, as where node gives me C:\Program Files\nodejs\node.exe and which node gives me /c/Program Files/nodejs/node and echo $PATH does have /c/Program Files/nodejs included.
If I type another command (such as ls), it actually will work even though I will continue to not be able to see my input.
I think this problem arose after the latest Windows 10 OS update was pushed to my system (10.0.17763). I've tried reinstalling Git for Windows and Node, and neither have resolved the issue. I can't find any other settings that might be affecting this.
Using Git CMD or Windows CLI is a workaround, but neither of those have a "Git Bash Here" option, which is the #1 thing I want this for. It is also nice that I get the visual indication of branch in Git Bash where I do not get that with Git CMD or the Windows CLI.
I don't need or want to use Git GUI, and besides that won't allow me to run local node files which I need to do for testing.
Does anyone have any ideas on how I can get Git Bash working with node again?
UPDATE: By running stty -a after node fails, I see that echo has flipped to -echo, which is why I can't see the input anymore. But that doesn't explain why node isn't loading and echo is getting turned off. Hoping that gives someone some additional context to figure out what's going on here. brkint, icrnl, ixon, opost, isig, and icanon are also getting flipped to the - versions after attempting to run node.
There are 2 possible workarounds (based on what your problem is) that I have tried-
Enter node first of all:
1) Try typing in reset and hit enter. You may not be able to see the input logging in, in the bash terminal window, but it works after that.
2) Or try typing any random alphabet and hit enter(again you won't see it on the screen),it will throw a 'command not found' error but you will have node working after this.
I am afraid these aren't exactly proper fixes, but they get the job done.
More information can be found here: https://askubuntu.com/questions/171449/shell-does-not-show-typed-in-commands-reset-works-but-what-happened/172747#172747
I've installed nodejs as described here.
Everything works fine when I ssh to the server myself. But I've created a script that deploys my application and call it via bitbucket pipelines. Everything else works fine (composer install, php artisan migrate etc.), except npm install. The error message is
./deploy: line 26: npm: command not found
In bitbucket-pipelines.yml I call my script like this:
- step:
script:
- ssh user#ip_address ./deploy
When I call the script by myself everything works. The problem is only with bitbucket pipelines. I have no clue why this happens :(.
Running which composer revealed that at least composer command is not getting picked up from your assumed location i.e., ~/composer dir. Instead, it was found in /opt/cpanel/composer/bin/composer.
which npm returned the following:
no npm in (/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/opt/bin:/opt/cpanel/composer/bin:/home/handmast/.local/bin:/home/handmast/bin)
Now since you are able to manually run the command npm, you just need to figure about the path from where npm is running and ensure that the path is explicitly added to the user's ~/.bashrc file and things should work fine. You need to do this because as per your observation, ssh is not able to find it.
export PATH=$PATH:/path/to/npm/binary
Note: To avoid any confusion, just remember that while adding the path to your binary, you just have to add the path to the directory where npm resides. Don't add npm at the end. For example, following is incorrect way:
export PATH=$PATH:/home/handmast/bin/npm
Correct way is this:
export PATH=$PATH:/home/handmast/bin
Before I start, I want to say that I already checked these answers:
Jenkins build step fails on 'npm install <whatever>'
Jenkin's build failing on npm install
Now, I'm dealing with this issue for a while already and thus I tried a bunch of stuff.
Firstly, I installed node + npm via homebrew. A simple $ node -v and $ npm -v echoed the version v0.10.36 for node and v2.3.* for npm, which also means I HAVE THEM IN THE PATH and they work while called in the terminal.
Simply adding node -v; npm -v to the execute shell in Jenkins didn't do it. After a bit of tinkering I copied what $: which node yielded in the terminal to the above mentioned script, which now looked like this: /usr/local/bin/node and apparently that worked. The Jenkins build succeeded and 'node-v0.10.36' was proudly displayed in the console output.
When doing the same for 'npm' which happened to be /usr/local/bin/npm --version the computing gods weren't so merciful anymore. A big 'env: node: No such file or directory' error was thrown this time and the whole build failed.
The actual command that fails is
$ /bin/sh -xe /var/folders/wr/g_dl81tn5_x0t_yz3jw602cr0000gn/T/hudson8770480548136671253.sh and "surprisingly" when I run the same command in the terminal it succeeds.
I also uninstalled the homebrew node & npm versions and installed them afterwards via the package manager. Same results.
Ultimately I also did this: https://gist.github.com/DanHerbert/9520689, with no luck.
Notes:
I'm running Jenkins 1.613 and tried with 1.5**
I didn't create a "Jenkins" specific user but instead I'm using the admin. This happens to be the same user that Jenkins runs, since the who am i command inside the executable script yields the admin's user name.
sudo'ing doens't help
I'm also running the whole thing in a Virtual Environment - vagrant
I'm not running Jenkins as a deamon, as it's conflicting with xtools, but as a simple process
I also tried out jenkins-node plugin with various configs (can detail if needed)
Thanks a lot for your help, and let me know if you need any other info, screenshots, logs, etc.
I found my own solution. The problem was that the PATH although visible in shell was not exported for the Jenkins job, and so, the first workaround, as found here, was to export it in the actual script like so:
but this feels like a hack!
The right and elegant solution is to use Jenkins EnvInject Plugin and export the path in the added Properties content textarea on the configuration page, like so:
Manage Jenkins -> Configure System -> Global properties -> Environment variables