threejs build guide unclear - node.js

so i need to modify three.js.min and i need to rebuild it to have the changes take effect.
i did it before when it used to be via phyton, but the process & method seems to have changed.
i downloaded node.js as linked here in the quickstart guide: https://github.com/mrdoob/three.js/wiki/Build-instructions, and restarted my pc
this happens when i try to clone threejs as described:
the Quickstart says that i can also "download and unzip" the directory which i already did to work on it, but i am unsure where to place it and where the relative path starts.
so if i use cd ./three.js would the threejs folder be in the c:/programs/nodejs directory? do i need to register it first? am i on the completely wrong path?
sorry if this is a really dumb question, but the guide just does not make sense to me

ok so here are the mistakes i made:
i used the Node.js command window (from programs) instead of the windows cmd
i need to navigate to my threejs root folder containing the package.json file using cd ./nextFolder
now compiled & working without a problem

Related

How to install composer globally on a Linux PHP app service?

I have an app service for my PHP 8.0 application. Azure will only allow me to use Linux which is fine, but I'm having trouble installing composer globally.
Because only files inside of /home are persisted I'm not sure where I can place the resulting composer.phar file, in such a way that it is included in the PATH, and I can't find any relevant documentation, only relevant discussion I could find was this: https://learn.microsoft.com/en-us/answers/questions/3638/installing-composer-on-azure-app-service.html but it still didn't help.
Could anyone tell me either where to put composer.phar or whether there's a way to edit my path to point towards /home/composer.phar?
Thanks!
I found the right way.
If I echo'ed PATH it told me that /home/site/wwwroot was included in the PATH, so all that's needed is to move the composer file into wwwroot doing something like mv composer.phar /home/site/wwwroot/composer.

How to get the directory of the .exe for a Node.js pkg executable?

I'm compiling/building a Node.js project into an .exe using Vercel's pkg but I'm trying to find where that executable file is during the program's runtime. To clarify, I want the Node.js program to know where the .exe file it is being run from is, to confirm it is correctly installed.
Context:
I cannot guarantee where the user has the .exe stored the first time they run it, but I want it to copy itself to the AppData folder so I can setup a Windows service from it, if it's not being run from there already. This in hopes of making a self-installing program, that doesn't require me to build an installed around it.
So on it's first run, I need the location of the .exe to be able to copy where I want. I might just have not picked it up, but I can't find an answer on either the pkg documentation or on another question here.
What I've Tried: I have tried process.cwd, process.pkg, __filename, __dirname and so on, but they all lead to the wrong thing, usually the snapshot folder of files.
When it comes to the main script it's as simple as finding it:
process.argv
From the Node.js documentation
Pkg from Vercel, is not an installer, its just a packager that will package node binaries and your code in a single exe.
You can follow this tutorial that shows how to make an installer it even enables you to set a path of where you want your exe to be installed

Installing Node in a linux grid server

So some background, I'm installing Node on a host server, but it's a grid server not a server that's solely for my website.
The grid server doesn't have a root user/ administrative powers. So to install node I found this workaround: http://iantearle.com/blog/media-temple-grid-and-nodejs . It's a Linux Grid server, I've never used Linux so if someone could explain to me what the commands mean, especially: ./configure --prefix=~/opt/
Lastly I followed the steps but when I try to run the node command in the server it says node:command not found - which is why I'm trying to understand the steps. Thanks
To explain the process:
Configure
The configure script is responsible for getting ready to build the software on your specific system. It makes sure all of the dependencies for the rest of the build and install process are available, and finds out whatever it needs to know to use those dependencies.
Unix programs are often written in C, so we’ll usually need a C compiler to build them. In these cases the configure script will establish that your system does indeed have a C compiler, and find out what it’s called and where to find it.
Make
Once configure has done its job, we can invoke make to build the software. This runs a series of tasks defined in a Makefile to build the finished program from its source code.
The tarball you download usually doesn’t include a finished Makefile. Instead it comes with a template called Makefile.in and the configure script produces a customised Makefile specific to your system.
3.Make Install
Now that the software is built and ready to run, the files can be copied to their final destinations. The make install command will copy the built program, and its libraries and documentation, to the correct locations.
--prefix=~/opt/ -> will set the build directory to /home/yourhome/opt directory.
Now if you didnt get errors while doing those 3 steps explained above make sure you did the following:
nano ~/.bash_profile
export PATH=~/opt/bin:${PATH}
nano is a text editor and you are opening .bash_profile file with it.
you need to add export PATH=~/opt/bin:${PATH} in that file and save it using ctrl+x
Then restart your terminal.
Specified github repository for nodejs is outdated. use the following link instead.
git clone https://github.com/nodejs/node.git
P.S node:command not found usually happens when the program is not installed correctly or it's executable isnt in your terminal's PATH variable.

How do I deploy Node.js applications as a single executable file? [duplicate]

This question already has answers here:
How to make exe files from a node.js app?
(20 answers)
Closed 7 years ago.
Supposed I have written a Node.js application, and I now would like to distribute it. Of course, I want to make it easy for the user, hence I do not want him to install Node.js, run npm install and then manually type node app.js.
What I'd prefer was a single executable file, e.g. an .exe file on Windows.
How could I approach this?
I am aware of this thread, anyway this is only about Windows. How could I achieve this in a platform-independent manner? Any ideas? Best practices? ...?
The perfect solution was a "compiler" I can give a source folder to. The source folder contains the app itself in various .js files, the node_modules folder and some metadata, such as the package.json. The output should be binaries for various platforms, such as Windows, OS X and Linux.
Oh, and what's important: I do not want to make any changes to the source code, so calls to require with relative paths should still work, even if this relative path is now inside the packaged app.
Any ideas?
PS: I do not want the user to install Node.js independently, it should be included inside the executable as well.
Meanwhile I have found the (for me) perfect solution: nexe, which creates a single executable from a Node.js application including all of its modules.
It's the next best thing to an ideal solution.
First, we're talking about packaging a Node.js app for workshops, demos, etc. where it can be handy to have an app "just running" without the need for the end user to care about installation and dependencies.
You can try the following setup:
Get your apps source code
npm install all dependencies (via package.json) to the local node_modules directory. It is important to perform this step on each platform you want to support separately, in case of binary dependencies.
Copy the Node.js binary – node.exe on Windows, (probably) /usr/local/bin/node on OS X/Linux to your project's root folder. On OS X/Linux you can find the location of the Node.js binary with which node.
For Windows:
Create a self extracting archive, 7zip_extra supports a way to execute a command right after extraction, see: http://www.msfn.org/board/topic/39048-how-to-make-a-7-zip-switchless-installer/.
For OS X/Linux:
You can use tools like makeself or unzipsfx (I don't know if this is compiled with CHEAP_SFX_AUTORUN defined by default).
These tools will extract the archive to a temporary directory, execute the given command (e.g. node app.js) and remove all files when finished.
Not to beat a dead horse, but the solution you're describing sounds a lot like Node-Webkit.
From the Git Page:
node-webkit is an app runtime based on Chromium and node.js. You can write native apps in HTML and JavaScript with node-webkit. It also lets you call Node.js modules directly from the DOM and enables a new way of writing native applications with all Web technologies.
These instructions specifically detail the creation of a single file app that a user can execute, and this portion describes the external dependencies.
I'm not sure if it's the exact solution, but it seems pretty close.
Hope it helps!
JXcore will allow you to turn any nodejs application into a single executable, including all dependencies, in either Windows, Linux, or Mac OS X.
Here is a link to the installer:
https://github.com/jxcore/jxcore-release
And here is a link to how to set it up:
http://jxcore.com/turn-node-applications-into-executables/
It is very easy to use and I have tested it in both Windows 8.1 and Ubuntu 14.04.
FYI: JXcore is a fork of NodeJS so it is 100% NodeJS compatible, with some extra features.
In addition to nexe, browserify can be used to bundle up all your dependencies as a single .js file. This does not bundle the actual node executable, just handles the javascript side. It too does not handle native modules. The command line options for pure node compilation would be browserify --output bundle.js --bare --dg false input.js.
There are a number of steps you have to go through to create an installer and it varies for each Operating System. For Example:
on Mac OS X you need to create a .pkg, there are instructions on how to do that here: https://coolaj86.com/articles/how-to-create-an-osx-pkg-installer.html
on Ubuntu Linux you need to create a .deb, there are instruction on how to do that here: https://coolaj86.com/articles/how-to-create-a-debian-installer.html
on Microsoft Windows you need to create a .exe or .msi, there are instruction on how do that using the innosetup installer here: https://coolaj86.com/articles/how-to-create-an-innosetup-installer.html
You could create a git repo and setup a link to the node git repo as a dependency. Then any user who clones the repo could also install node.
#git submodule [--quiet] add [-b branch] [-f|--force]
git submodule add /var/Node-repo.git common
You could easily package a script up to automatically clone the git repo you have hosted somewhere and "install" from one that one script file.
#!/bin/sh
#clone git repo
git clone your-repo.git

Call Download node app dependencies from another node application

i have a command tool application developed using node. when pointed over a folder when i run a command it should install the node dependencies specified in the package.json file in the folder. is it possible to do like this.
You need to use
exec = require('child_process').exec;
exec(#your command starts here
But in general you should do googling before asking questions: http://nodejs.org/api/child_process.html
also remember that user under which your tool is executed should have access rights to do so (e.g. root or destination folder owner)
PS: sorry for bad formatting and little text - typed from phone :)

Resources