Where is the "program" module that some bash scripts require before launching Node.JS? - node.js

I found a Bash script today that uses the env command to launch Node.JS. The script requires two packages and then uses the second package to parse the process command line arguments before launching node as shown below:
#! /usr/bin/env node
'use strict';
require('zos-lib').Logger.silent(false);
require('./program').parse(process.argv);
I can't find a module/package named './program' anywhere in my file system. Can someone tell me where the program module/package is and what it does? I tried many Google searches but unfortunately program is such a common keyword that I'm not finding anything useful.
UPDATE: slebetman's answer is correct. I wanted to explain why I couldn't find the program module in this update, in case it helps others. As soon as I read his answer about that script being a Javascript script and to look for program.js not program I found it by searching the directory tree from the top level Node.js directory with this command:
$ find . -iname program.js
Unfortunately for me, what you see below is what I tried the first time and that does not produce any output:
$ find . -iname program

The script you found is not a bash script. It is a javascript script. Specifically it is a script written in javascript for node.js.
In node's require system, a module name that begins with ./ means that the module is in the same folder as the script.
You haven't told us the file name of the script you posted. But lets assume it's called myscript.js. Then the folder structure should be:
/whatever/folder/myscript.js
/whatever/folder/program.js
or
/whatever/folder/myscript.js
/whatever/folder/program/index.js
or
/whatever/folder/myscript.js
/whatever/folder/program/package.json
/whatever/folder/program/whatever_script_name.js
If you cannot find the file program.js or the folder program in the same folder as the script you are looking at then you haven't copied the script properly (you forgot to copy the "program" file or folder).

Related

Possible way to create a command line tool in node.js

I am building a nodejs based small framework for my application. Say, the name of the framework is coffee-cup, situated in the folder of the same name. The folder has a structure inside. To simplify the work of developers, I want to add few command line methods. For example, consider following folder structure.
coffee-cup
|--config
|--cups
|--cup1
|--index.js
|--report
|--cup-config
|--cup2
|--index.js
|--report
|--cup-config
We see that inside cup1 and cup2, there is same structure. If a developer wants to add a new cup called cup3, they will need to create a folder called cup3 and add the underlying structure into that folder.
To automate this task, I am thinking of a way to build a command line utility like
$ coffee-cup new cup cup3
that can work on linux, windows or mac terminals.
Expected result of Entering this command in terminal: would create a new folder called cup3 in cups folder and will create the file index.js and folders reporting and cup-config inside the folder cup3.
I can create folder using fs.mkdirSync()and file using fs.writeFile().
I am however, unable to find a way to make the terminal identify the coffee-cup command. If terminal identifies this command, it should collect the following arguments and pass on to the nodejs file and I can continue from there. What I know is, that there exist npm packages like inquire which are useful in creating command line applications. But it does not help in building command line utilities like I mentioned above.
So I am looking for guidance on making terminal identify the coffee-cup command, collect the following arguments and pass on everything to a nodejs file. It is just like we install npm and then terminal starts identifying the npm keyword and subsequent commands like $ npm install. Any help by experts will be highly appreciated.

What-dir reporting own directory as current directory in Rebol

I am running Rebol on Debian Stable Linux and I have put rebol executable in /usr/local/bin. Then I have created following script file and also kept it in /usr/local/bin:
#! /usr/local/bin/rebol
REBOL []
print what-dir
quit
However, when I run this script from any directory, it only reports "/usr/local/bin/" and not current working directory. I want to get current working directory to perform operations from code.
Following code, using Linux shell command pwd (print working directory) also reports the same:
print call "pwd"
How can this problem be solved?
You can find your own directory where you are in system/options/path and if you want it to be your current working directory and what-dir to report your own directory as current directory, you have to add this line
system/script/path: system/options/path
or
change-dir system/options/path
before calling what-dir.
Even call "pwd" uses and shows now your own as current directory under Linux
I agree, this behaviour is quite unintuitive.
I came across the same situation a while ago, and I kept on making the same mistake over and over... I eventually placed that change-dir system/options/path in a more general routines script, which is loaded from my ~/.rebol/view/user.r.
Mind you though, one could also put that statement within the user.r.

/usr/bin/env: node --harmony: No such file or directory

I have searched online thru this site and others for a solution, so I finally bow my head and ask for help. It looks like most of the answers are identifying the node/nodejs naming conflict and creating symlinks as a solution. I don't have a nodejs anywhere on my system.
I am using a _ n _ as my node version manager. So,
sudo n
displays a list of installed versions and allows me to choose. n simply copies the chosen version into /usr/local/bin/ as node. It has already established a link from /usr/bin/node to the managed version.
I installed a javascript library called 'waigo.' When I run the following:
waigo init
I get the following output...
/usr/bin/env: node --harmony: No such file or directory
arrgghhh..... I'm frustrated. Any help will be appreciated.
It looks like a problem with the shebang line in a shell script which specifies the program used to interpret the file. This might look like:
#!/usr/bin/env node --harmony
The error message in your case suggests that env is attempting to locate "node --harmony" which was probably a problem with the executable file run when you typed waigo. For example, it might have had a shebang line incorrectly formatted like:
#!/usr/bin/env "node --harmony"

Linux shell commands not found even though their paths are listed in the PATH variable

The google app engine cli commands cannot be found in the python sdk. I've already checked the google_appengine file. The shell commands are there, and I already added the app engine file path to the PATH variable. I echo the PATH variable and the directory to the app_engine file shows up, but still shows not found when I try to use a command that's inside the file. If I reference the command directly by using its whole path, the command works, but otherwise it won't. Is there anything else that needs to be done to reference a command in shell?
More error info please,
If I reference the command directly by using its whole path, the command works
I think your python path maybe wrong, Python 2.6 is not supported.
so are you have mulit-version python?
Thank you for your contributions everyone. It turns out the path I was using was wrong. Instead of /home/Programs/Apps/google_appengine it should have been /home/Programs/google_appengine. I guess the shell doesn't check to see if the path you add to the PATH variable actually exists. Who knew? Not me
Until I run into another problem stack overflow--which may be soon
See ya

Node: Move the current directory of the interactive shell

I'm writing a little CLI tool for Node.js. There are some situations where I'd like to run modify the current directory of the shell that runs my program:
some/location$ myProg moveToSomewhere
some/other/location$
child_process can't help here, since its commands run in a different shell.
Is there a way to do this?

Resources