I was thinking , would it be helpful and efficient to get a notification(sound or popup) back after npm finish running a task , a long installation for example . I'm using vscode and running most of my command in the integrated terminal and while waiting for it to finish I ended up spending more time on doing other task that is non-productive.
So we can break this down to running npm install, followed by some way of making a sound. According to this thread, a simple beep can be done using:
echo -en "\007".
Combine these two, and you get:
npm install; echo -en "\007"
The use of ; ensures that the beep is played even if npm install fails (as opposed to && which only runs the beep if the first command is successful). You could also look here for how to start playing a song with VLC: play-only-audio-with-vlc
If your npm install is part of a task, VSCode 1.72 (Sept. 2022) will offer:
add audio cue for task end and terminal bell
Fixes "Play sound upon completion of build so that users can multi-task (do work in other applications) and know when the build has completed "
Settings audioCues.taskEnded
This has been released to VSCode Insiders yesterday.
for cmd like Terminals
Your_Command && [System.Media.SystemSounds]::Beep.Play()
Sounds:
Beep, Hand, Quetsion, Asterisk, Exclamation
You can also play the raw sound and changes its pitch and duration
[console]::beep(1000,500)
For a slightly different solution there is a npm package named benny-hill:
Play the Benny Hill theme while running another command
e.g.
npx benny-hill npm install
will play Yakety Sax while you're waiting.
Actually there is a npm package doing exactly what you are asking for:
Literally tells you when a command is done running.
E.g.
npx okimdone npm install
It depends on external speech to text tools like espeak or festival to produce the audio.
Related
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'm not a coder (just wanted to get that out there). I read an article about creating a silent doorbell (I have a dog that's insane).
https://github.com/initialstate/silent-doorbell/wiki/Part-2.-Finding-the-Button's-Address
I'm relatively computer literate. I followed the instructions for windows and download node.js. The instructions say to open a node.js command prompt and put in the following command:
sudo apt-get install npm
sudo apt-get install libpcap-dev
npm install node-dash-button
the problem i'm having is 1) I'm getting an error saying "apt-get" is not recognized as an internal or external command operable program or batch file.
Reiterating that I am no nowhere near as sophisticated as the users i've seen on here and am just a guy trying to keep the baby sleeping b/c the dog can't shut up - is anyone able to help so I can then go to the next step of instructions?
Thanks so much in advance.
Brad
sudo apt-get is a linux packet manage, so you wouldn't want to do this on windows. As they have mentioned raspberry-pi's I gather that they have made the assumption that you would be on linux.
If you ran that command in a linux terminal it would install the preqequisites and then install node-dash-button in node.
Try just running the nodejs packet manager part:
npm install node-dash-button
The rest of that line is not node or windows.
Hopefully this will get you to the next stage :)
The whole tutorial asumes you being on a Linux/Unix system.
If you solve this issue you will run into the next if you don't know what the commands mean and how to translate them to windows.
For example
sudo node bin/findbutton
is a linux/unix command as well (which is the next step in your tutorial).
So i strongly suggest setting up a VM with linux (debian should do).
I am trying to see how much time npm install takes to complete installing all my dependencies. Is there a way for me to time this process, natively (in npm) or using some third party plugin? I've tried
* npm i --verbose
* npm i --silly
* slow-deps (A third party lib that analyzes your npm packages)
slow-deps gave me a decent result, but I am not sure about it's accuracy, as it doesn't run as part of the npm install process.
Is there any other way to accurately time-profile the npm install process? I'm looking for an output like this (output screenshot from Yarn):
Thanks for your help. I have come across a few utilities for this:
The time utility mentioned by #JJJ in the comments section.
Paypal's gnomon package, that updates timestamps to everything.
Use time linux command and have the following command:
time npm install
Also according to https://www.commandlinux.com/man-page/man1/time.1.html
Users of the bash shell need to use an explicit path in order to run the external time command and not the shell builtin variant.
so your command may be (I am a macOS user and I am using the below command):
/usr/bin/time npm install
The output of this command (at the last line) would be something like this:
153.96 real 67.63 user 34.12 sys
so basically what you are looking at is the real number that are in seconds. To the above example the time taken is:
153.96s
I am trying to install node.js. I followed this tutorial and i am stuck in the middle.
When I write ./configure in my cygwin terminal it says "cygwin not supported". Please help me out
Thanks in advance.
Node in my experience runs fine in cygwin, what Node usually has EINVAL errors in seems to be MINTTY which is a terminal emulation 'skin' that is default to cygwin. I still am not sure why these EINVAL errors happen 100% but the following are the steps and tricks I use to get node working.
In my /cygwin/home/{username}/.bashrc I add node to path so cygwin can find it
export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"
If you run a 32 bit version of node:
export PATH=$PATH:"/cygdrive/c/Program Files (x86)/nodejs/"
Then to make npm run without windows to linux issues I launch cygwin in admin mode then run:
dos2unix '/cygdrive/c/Program Files/nodejs/npm'
At this point running files and most npm packages will run in MINTTY just fine, although every once and awhile you will run into EINVAL issues with certain npm packages as karma. Also you will not be able to run the interpreter directly in MINTTY, anytime I want to do these things I run:
cygstart /bin/bash
This will open a native cygwin bash.exe window, from here you run the interpreter or an any troubling package command that results in a EINVAL. It slightly sucks you have to do this but I rarely use this day to day, and I love MINTTY too much to not use it.
Also note that you can run any one line node code in MINTTY by just running something like:
node -e "console.log('hello node')"
As a simpler derivative of troy's answer for those just looking to install NPM packages:
Install Node.js with the Windows installer package.
Add it to the PATH with export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/" (obviously replacing the path to Node.js's installation directory with where you installed it).
There's a current bug in the Windows version that can be fixed by running mkdir -p ~/AppData/Roaming/npm. This is a bug for all of Windows and not just Cygwin. At some point of the future, you won't have to do this anymore, but the command shouldn't have any negative side effects.
Test it. Eg, npm install pretty-diff -g.
In order to be able to run the newly installed software, you'll need to add the install locations to your PATH. You can find these with npm bin -g and npm bin (the -g flag is the "global" installation location).
Not really anything special that you have to do to get it to run in Cygwin (although I can't say if everything works).
Use Console2, it allows you to run create tabs of CLI shells. It seems running cygwin inside console2 allows me to use node REPL just fine. I have no idea why :P
Follow this guide to add cygwin to console2:
http://blog.msbbc.co.uk/2009/11/configuring-console-2-and-bash-with.html
With Bjørn's suggestion (using Console2) and Soyuka's alias (steps here), my node.js v0.10.13 and npm v1.3.2 are now working under Babun v1.02, a Cygwin distribution.
For windows, Just run bash.exe in cmd, so that you could have a bash work around with cmd console directly, which could support ALL NODE WORKING PERFECTLY.
C:\Users\郷>bash
郷#CHIGIX ~
$ node
>
I'm using this wrapper in /usr/local/bin/node (note no extension!)
#!/bin/sh
_cmd="$(cygpath -lw -- "$1" )"
shift
"/proc/cygdrive/C/Program Files/nodejs/node.exe" "$_cmd" "$#"
This is far from perfect, as Node do not understand Cygwin directory tree, but works relatively well with relative names.
From Windows, run Cygwin.bat (instead of Cygwin Terminal) then in that run node: see and reply on this answer on this effectively-same question asked 1.5 years later.
Grab and run the node.js Windows installer.
In the Cygwin prompt type node
See if it works.
Is there a commonly used approach for displaying 'how to get started' instructions to a user after a .deb installer has finished installing a package?
I need an approach that works for users working via a terminal as well as from a desktop environment.
Server admins will probably know to check for a README file but many others won't.
I'd suggest running the "tty" command from your postinstall script. That will tell you if you have a tty and are running as a terminal program. Once you know that you could either "more" a readme file if you're running in terminal mode or you could call "gnome-text-editor" if not. You might also want to put in some detection to check "/etc/lsb-release" so that you know what distribution your .deb is being installed on and which editors will be suitable.
I use the tty command like Benj suggested, but I use the dialog command to display post install chatter if its available on the system.
Try this command:
dialog --backtitle "All done" --title "Installation complete" --textbox /etc/passwd 0 0
... but replace /etc/passwd with your README of choice. Its a much nicer way to scroll through information.
After a bit of experimentation it looks like I can detect how the .deb package has been installed by checking the value of the DEBIAN_FRONTEND variable in the postint.sh script. When run from the desktop it contains the value 'gnome', but when run via dpkg from the command-line it isn't set, so something like this might work:
HELP_URL="http://mysite.com/help.html"
if [ "$DEBIAN_FRONTEND" = "gnome" ]; then
nohup gnome-www-browser $HELP_URL &
else
echo For help visit $HELP_URL
fi