Building a JavaScript build system in Sublime Text - javascript

I'm trying to work on an application using node.js, and am trying to build a JavaScript build system in Sublime Text 3 on my Ubuntu OS. I created a new build system file in Sublime Text called nodey.sublime-build, the contents of which were:
{
"cmd": ["node","$file","$file_base_name"],
"working_dir": "${project_path:${folder}}",
"selector":"*.js"
}
Now, my node.js installation is stored in the following path: /tmp/node-v0.12.7-linux-x64.
However, when I try to run a JavaScript file called chat.js which is stored in the following location: /opt/lampp/htdocs/chat/chat.js, Sublime Text throws the following error:
[Errno 2] No such file or directory: 'node'
[cmd: ['node', '/opt/lampp/htdocs/chat/chat.js', 'chat']]
[dir: /opt/lampp/htdocs/chat]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]
[Finished]
I'm not really sure if this is the right method for creating a new build system. After building the nodey build system, I went to Tools -> Build System and selected nodey.
What seems to be wrong with my settings?
EDIT:
I ran a sudo apt-get install node inside the same directory as chat.js , and now when I try to run the JavaScript file in Sublime Text, I get this:
[Finished in 0.0s with exit code 1]
[cmd: ['node', '/opt/lampp/htdocs/chat/chat.js', 'chat']]
[dir: /opt/lampp/htdocs/chat]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]
However, even though there are no noticeable errors, the output of the file, which included a console.log("Hello World"), wasn't displayed.

For anyone else encountering the same error, try running the following in your terminal if you're a Linux user:
sudo apt-get install node
sudo apt-get install nodejs-legacy
This solved the problem in my case.

Related

How to set up http server correctly in MacBook Pro 2021

I think I set up wrongly, in my terminal using "npm install --save http-server" from this website
Problem with npm install --global http-server
how to uninstall it
//
how to know if I have http server install? for example I can check if I have node in my terminal by typing "node -v"
//
I try to do exactly as this video
https://www.youtube.com/watch?v=FjWbUK2HdCo&list=PLRqwX-V7Uu6Zu_uqEA6NqhLzKLACwU74X&index=5
Google it found this website https://docs.w3cub.com/npm/getting-started/fixing-npm-permissions.html
using sudo npm install http-server -g, type in my Password, then got a pop up screen don't know what to do next, so I just click and fail 3 time again, anyone know how to bypass it?
//
I also having trouble opening zsh file in vscode using terminal due to error, so I just not open it in vscode but just plain text, and edit it in plain text, is that also the correct way? or do I need to open the zsh with vscode?

How can I use ffplay from Electron.js app?

I've installed ffplay in my working folder (in bin subfolder) using ffbinaries (ffbinaries downloader). My current platform is linux-64.
I've use:
var spawn = require('child_process').spawn,
player = spawn('./bin/ffplay', ['http://path_to_video_file']);
but got an error in terminal stderr:
./bin/ffplay: error while loading shared libraries: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory child process exited with code : 127
How can I get access from my javascript code to this binary for playing videos or how can I get ready-to-use binary which is a built-in for my Electron app?
...Or how can I get all of ffplay possibilities for playing videos inside Electron app?
Thanks in advance!
The error you get means that ffplay cannot find libSDL.
First, make sure the library is installed by opening a terminal window and typing:
sudo apt install libsdl2-dev
If it wasn't installed, try to run your program again after it was installed.
If you still have the problem, type the following in your terminal window:
export LD_LIBRARY_PATH="/usr/local/lib"
Try again to run your program. If the problem is now solved, edit the file etc/environment and add the setting there to make it permanent:
sudo nano /etc/environment
Add this LD_LIBRARY_PATH="/usr/local/lib" at the end, exit and save.
Hope it helps.

vscode-ripgrep not getting installed in VSCode build/run process

I was trying to build and run VSCode on my Ubuntu 17.10 using the following guide: https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run
When I tried to install dependencies using yarn, it is giving me the following error:
error /home/dhairyakhale/git/vscode/node_modules/vscode-ripgrep: Command failed.
Exit code: 1
Command: node ./lib/postinstall.js
Arguments:
Directory: /home/dhairyakhale/git/vscode/node_modules/vscode-ripgrep
Output:
Unzipping to /home/dhairyakhale/git/vscode/node_modules/vscode-ripgrep/bin
And then it stops the process. How do I proceed?
I have a similar issue while installing Theia. The broken vscode-ripgrep installation caused it. Here is the ticket I submitted to vscode-ripgrep.
https://github.com/roblourens/vscode-ripgrep/issues/15

Gulp-plumber not found in Ubuntu OS, but found in Windows OS on dual boot

I am following a tutorial, and I am supposed to have a gulpfile.js running, but I'm encountering a strange situation. Gulp works in one location and does not work in the other.
I have a dual boot for Ubuntu and Windows 8.1. In the Ubuntu OS Documents directory the gulp command does not work, but returns an error saying "'gulp-plumber' not found". I don't understand why since the folder structure is exactly the same. If I change directory to the windows volume and access the main project folder, when I type "gulp" everything works fine.
Additionally, if I CTRL-C in the command line, the gulp command stops working and returns an error saying:
events.js:163
throw er; // Unhandled 'error' event
Error: write EPIPE
So how can I run the gulp command again? Is it through ps aux, check something running and then kill it?
github.com/DannyS95/Project
This issue has been fixed, i had to install gulp plumber, because i did not have that package in the package.json file.
Then a quick npm install, and since i have gulp globally i can just run gulp and voila, it works.

Run Geany as root

I have ubuntu 16.04 and I installed Geany using Ubuntu Software Centre. I need to edit some php and js files which happen to be in root directories. So when I try to save the changes in Geany, it generates following error:
Error opening file '/var/www/html/project1/team/team.php': Permission denied
The file on disk may now be truncated!
How can I make Geany to edit and save these files?
try
gksudo geany
Use gksudo with graphical apps written in GTK+ instead of sudo
sudo -Eb geany
worked for me on Debian 10 with xrdp. I executed the command on xrdp desktop Terminal Emulator.
-E: preserve user environment when running command
-b: run command in the background
Note that without -b option the control will not return to terminal until geany is closed.
Not an expert on this, was just trying to see sudo's options and this did the trick!
sudo geany
but you really shouldn't edit your code in production environment
if you are developing locally navigate to your www file using terminal
after that you have to change the permission to 777 using this command
sudo chmod 777 html
which mean every one can read-write-execute your files
REMEMBER THIS IS FOR LOCALLY DEVELOPING

Categories