Fixing "Killed: 9" error when running "node" - javascript

When I run node I get Killed: 9. I've restarted, uninstalled node, uninstalled npm and uninstalled n and then reinstalled all of them.
After reinstall. Node initially will work, i.e. running node will open a REPL. However, upon running npm install -g n and running n, node becomes broken again.
This is true for every version of node. The executable becomes broken. There's a stack trace to my n installation for failing at this:
execute_with_version() {
test -z $1 && abort "version required"
local version=${1#v}
if [ "$version" = "latest" ]; then
version=$(display_latest_version)
fi
if [ "$version" = "stable" ]; then
version=$(display_latest_stable_version)
fi
if [ "$version" = "lts" ]; then
version=$(display_latest_lts_version)
fi
local bin=${VERSIONS_DIR[$DEFAULT]}/$version/bin/node
shift # remove version
if test -f $bin; then
$bin "$#"
else
abort "$version is not installed"
fi
}
Advice?
Solution (but not really)
Don't use the program, in this case n, after corrupting the process. I switched to nvm and that seems to work. I force terminated a foreman process that was using node. My guess is that it didn't clean up what it needed to and was still being cached even on new installations (please someone correct this).

It happened to me after i accidently involved node's "n" command. Now i ran "n" again
Press enter and everything was fine after.

Related

Streamr node install on putty (issues)

The guide I am using https://www.youtube.com/watch?v=9cdsQWRDNM4 time marker (7:27) is where it goes to all wrong.
This is where I am having issue with my Streamr node install. Its a very basic install. The issue I am having is I'm very new to putty and this section isn't the same as the install is supose to be -- /root/.streamr/config/default.json but when I change it it becomes another error. The following sentence is what I am generating which becomes an error also which prevents myself from starting my node up (on my vps) Select a path to store the generated config in /home/streamr/.streamr/config/default.json
Either way I am getting an error.
**This is a screen shot of what I am dealing with !!! Any help with putty and setting up VPS would be great. **
can provide actual screenshot if needed!!
: Welcome to the Streamr Network
: Your node's generated name is Leopard Wrist Pond.
: View your node in the Network Explorer:
:
: You can start the broker now with
: streamr-broker /home/streamr/.streamr/config/default.json
root#ubuntu-s-1vcpu-1gb-tor1-01:~# docker run -it -p 7170:7170 -p 7171:7171 -p 1883:1883 -v $(cd ~/.streamr Docker; pwd):/root/.streamr streamr/broker-node:latest streamr/broker-node:lates **Error: Config file not found in the default location. You can run "streamr-broker-init" to generate a confi g file interactively, or specify the config file as argument: "streamr-broker path-to-config/file.json"
at readConfigAndMigrateIfNeeded (/home/streamr/network/packages/broker/dist/src/config/migration.js:155 ** :19)
at Command. (/home/streamr/network/packages/broker/dist/bin/broker.js:20:69)
at Command.listener [as _actionHandler] (/home/streamr/network/node_modules/commander/lib/command.js:48 8:17)
at /home/streamr/network/node_modules/commander/lib/command.js:1227:65
at Command._chainOrCall (/home/streamr/network/node_modules/commander/lib/command.js:1144:12)
at Command._parseCommand (/home/streamr/network/node_modules/commander/lib/command.js:1227:27)
at Command.parse (/home/streamr/network/node_modules/commander/lib/command.js:897:10)
at Object. (/home/streamr/network/packages/broker/dist/bin/broker.js:41:6)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
npm notice
npm notice New major version of npm available! 8.19.3 -> 9.4.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.4.2
npm notice Run npm install -g npm#9.4.2 to update!
npm notice
Ive tried both ways for the file name but both end in errors. Im nt sure why its not generating a /root/.streamr/config/default.json. Its giving me this strange file name that doesn't work either streamr-broker /home/streamr/.streamr/config/default.json. This one will let me finish the set up of the docker but it will not let me start the node and generates an error as seen in the code!

The token '&&' is not a valid statement separator in this version

On the way of installing Webpack on my React Project, the following problem hinders my progress:
last step to configure the Webpack
npm run build && node ./dist/main.js
Error on Windows Power Shell / on Visual Studio Code
PS C:\Users\pythonbuddha\Desktop\to_experiment\to-do-list> npm run build && node ./dist/main.js
At line:1 char:15
+ npm run build && node ./dist/main.js
+ ~~
The token '&&' is not a valid statement separator in this version.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvalidEndOfLine
Tutorial which promised to configure the webpack
https://developerhandbook.com/webpack/webpack-4-from-absolute-scratch/
https://developerhandbook.com/webpack/how-to-configure-scss-modules-for-webpack/
It's because you're in PowerShell, try running it in CMD or Git Bash
Alternatively (if you wish to continue in PS):
(npm run build) -and (node ./dist/main.js)
3rd Alternative, just run them separetly,
I found that within PowerShell as my terminal within VS Code, replacing && in the command with ; did the trick.
PowerShell (Core) v7+ - but not Windows PowerShell - now does support && and ||, the pipeline-chain operators, so your command should work as-is there - see this answer for PowerShell-specific considerations for their use; see below for Windows PowerShell workarounds.
Conceptual note:
In all shells that support it (notably cmd.exe and POSIX-compatible shells such as Bash), && conditionally sequences commands: it executes its RHS command only if the LHS command indicated success; || is the inverse: it executes the RHS only if the LHS indicated failure.
This is important for preventing execution when it makes no sense to do so; e.g., in npm run build && node ./dist/main.js it only makes sense to run what was just built (with node) if the build succeeded, which is what && ensures.
Windows PowerShell workarounds:
The most succinct workaround:
npm run build; if ($?) { node ./dist/main.js }
This builds on the automatic $? variable, which is a Boolean indicating whether the most recent command succeeded.
The most robust workaround, needed if the commands use 2> redirections:
npm run build; if ($LASTEXITCODE -eq 0) { node ./dist/main.js }
Basing the success test on the automatic $LastExitCode variable, which reflects the process exit code of the most recently executed external program, avoids problems in Windows PowerShell[1] where the presence of stderr output in combination with redirecting it via 2> mistakenly sets $? to $false even when the process exit code is 0.
[1] The problems with 2> redirections are summarized in this answer. They also plague PowerShell (Core) up to version 7.1
The && operator is used in linux bash to run both commands after each other. (Also if the first command fails, the second won't be executed)
This does not work in PowerShell on Windows so just split both commands and run them separately:
npm run build
node ./dist/main.js
For completeness, Powershell can behave the same when you do (command1) -and (command2) and && might actually work depending on your PowerShell version.
See this for further info: https://stackoverflow.com/a/564092/2232127
I have solved the issue by upgrading powershell and renamed dir. path folder name by removing spaces. Now it works properly.
Powershell upgradation link
https://github.com/PowerShell/PowerShell/releases/tag/v7.2.0-preview.8
Since some people might arrive here in the same manner as I did, wondering why PowerShell would not allow me to perform a conditional AND operator between two variables within an if statement.
I solved it by evaluating the Left Condition with an If condition, and then the Right Condition immediately within the first true condition.
Example that produced the error:
$Path = "C:\\Temp\test"
$RootPath = "C:\\Temp"
$currentChildren = Get-ChildItem -Force -LiteralPath $Path
$isEmpty = $currentChildren -eq null
if ($isEmpty && $Path -ne $RootPath) {
Remove-Item -Force -LiteralPath $Path
}
$foo = "question"
$bar = "answer"
Example that I used to solve the problem:
$Path = "C:\\Temp\test"
$RootPath = "C:\\Temp"
$currentChildren = Get-ChildItem -Force -LiteralPath $Path
$isEmpty = $currentChildren -eq null
if ($isEmpty) {
if ($Path -ne $RootPath) {
Remove-Item -Force -LiteralPath $Path
}
}

How to concat multiple bash commands?

Having this bash_profile commands, trying to run backend and frontend server in one single alias command i.e ins
alias is='ivui && npm run start:backend'
alias ib='ivbe && npm run start:dev'
alias ins='ib && is'
is referring to a different project folder and it starts the server and ib is also referring to a different folder and server. Trying to concat both, but the first one only triggers and concat of && is not executed.
Concat npm helps in combining both servers from single project folder, but wondering how we can get this done using bash_profile? so that by executing just ins, it must start backend server first and frontend also.
The reason your double alias command (ib && is) does not work is because, as per man bash:
Aliases allow a string to be substituted for a word when it is used as
the first word of a simple command.
Stands to reason that if you run ib && is where both ib and is are aliases, it will only run ib.
With that out of the way, there is have a different and, I believe, better solution to your problem. You can use screen to run those 2 commands in the background and also, as a bonus, have the ability to watch their terminal output any time you want.
The idea is this: 1. Start a screen session; 2. Open two windows inside that session; 3. Run npm run start:backend in 1st window and run npm run start:dev in the second window.
Here is what you need:
screen -S Servers -t backend_window -A -d -m
screen -S Servers -X screen -t dev_window
This will start a screen session with backend_window and dev_window inside it. Now you just need to run your 2 commands inside those windows:
screen -S Servers -p backend_window -X stuff $'npm run start:backend\n'
screen -S Servers -p dev_window -X stuff $'npm run start:dev\n'
Now both your npm commands are running in the background at the same time. You can just put these 4 lines into your .bashrc file and it will launch on log in.
But the best part about this approach is you can visually see what's going on with those npm commands by attaching the screen and looking inside those windows. Just run:
screen -rx Servers
This will show you your first window by default. Let's split the screen and show both windows side by side:
Ctr-A + | <- will split the screen into 2 sections
Ctr-A + Tab <- will shit cursor to the new section
Ctr-A + " <- will show you your 2 windows, just pick the dev
All this will give you this view
Keep in mind that both your npm commands will continue to run even after you log out. To kill them, either attach the screen as described above and then Ctrl-C both processes. Or just run killall screen and they will just die.
You could create a function and add your aliases inside, for example,
stopdev () (
cd "$HOME/website" && {
make website_stop
ret=$?
make backend_stop && return $ret
}
)
This example also has a return code, and has a subshell called to run the function, so the filepath is not $HOME/website after the function is called.
More information on the following webpage,
https://unix.stackexchange.com/questions/266063/why-cant-i-call-two-aliases-with

MEAN.io application not starting

I am trying to teach myself how to use the MEAN stack and I am working through the docs from the MEAN.io site. I am at the point where I run the following commands:
$ npm install -g mean-cli
$ mean init <myApp>
$ cd <myApp> && npm install
and these run just fine. But when I get to the next step which is to either just run
gulp
or
node server
and nothing happens. If I run gulp then after it gets to the part where it says
Finished 'development' after 6.15 μs
in the logs it just hangs there. If I run node server it just hangs and nothing else happens. In either case I see nothing at
http://localhost:3000/
Is this a common sticking point for people?

Need help with how to start using YUI YETI in Cygwin for JS testing

I'm new to a lot of things that YETI requires to run, and I've made it through most of the steps to get it to work. I have installed cygwin so I can run node.js and npm (I used these instructions). Once done, I ran npm install yeti, and yeti installed. Now I can type things like this:
This is where I'm having problems. I can't figure out how to get yeti to run the tests in demo.html. I can open up my browser to file:///C:/test/demo.html and I can see the tests run (it's a YUI Test) so I know that the problem is not demo.html being broken. Also, when I try to run yeti as a server (yeti --server), It sits there after the line "to run and report the results" and doesn't let me do anything unless I exit with ctrl-c, although I can go to localhost:8000 and see this:
If I try opening up a new cygwin console and doing this:
It gives me a bunch of errors that I don't understand.
Help!
How I did it on ubuntu:
First install node dependencies. Only install dependencies using apt-get
You need at least:
sudo apt-get install build-essential libssl-dev python2.6
Also this link could be helpfull => http://howtonode.org/how-to-install-nodejs (see ubuntu instructions).
Next install node/npm the correct way on ubuntu.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
close terminal and open it again
curl http://npmjs.org/install.sh | sh
After that install yeti issuing: $ npm install yeti#stable
Run yeti issuing from terminal:
alfred#alfred-laptop:~/node/stackoverflow/4833633$ yeti
Yeti will only serve files inside /home/alfred/node/stackoverflow/4833633
Visit http://localhost:8000, then run:
yeti
to run and report the results.
start the browsers you like. Point the browsers to => http://localhost:8000
inside the folder you started yeti write your tests.
alfred#alfred-laptop:~/node/stackoverflow/4833633$ ls -al
total 16
drwxr-xr-x 2 alfred alfred 4096 2011-01-29 01:47 .
drwxr-xr-x 6 alfred alfred 4096 2011-01-29 01:27 ..
-rw-r--r-- 1 alfred alfred 6140 2011-01-29 01:47 simple.html
See gist for a really simple example. I just copied to example from http://developer.yahoo.com/yui/3/examples/test/test-simple-example_clean.html but removed the <!--MyBlogLog instrumentation--> crap. I also told it not to render console by commenting line 196 => //r.render('#testLogger');(That last is not even necessary, but I think tests will run faster that way because it does need to render the console).
Finally I just ran:
alfred#alfred-laptop:~/node/stackoverflow/4833633$ yeti simple.html
Waiting for results. When you're done, hit Ctrl-C to exit.
✔ Example Suite on Chrome (8.0.552.237) / Linux
6 passed, 0 failed
✔ Example Suite on Firefox (3.6.13) / Linux
6 passed, 0 failed
Success :)
Some extra information about my distro
alfred#alfred-laptop:~/node/stackoverflow/4833633$ cat /etc/issue
Ubuntu 10.10 \n \l
alfred#alfred-laptop:~/node/stackoverflow/4833633$ python --version
Python 2.6.6
alfred#alfred-laptop:~/node/stackoverflow/4833633$ node -v
v0.2.6
alfred#alfred-laptop:~/node/stackoverflow/4833633$ npm -v
0.2.15
alfred#alfred-laptop:~/node/stackoverflow/4833633$ npm ls installed | grep yeti
npm info it worked if it ends with ok
npm info using npm#0.2.15
npm info using node#v0.2.6
yeti#0.1.2 The YUI Easy Testing Interface =reid active installed remote stable YUI web app YUITest TDD BDD yui3 test
npm ok

Categories