NODE_SHARED_MODE and __POSIX__ - node.js

What is the role of NODE_SHARED_MODE and POSIX macros in node.js source code ?
In which file they are defined?
These are present in node_main.cc in nodejs src directory

You can use GitHub's search feature (or grep in a local checkout) to search through Node.js's source code:
https://github.com/nodejs/node/search?q=NODE_SHARED_MODE
https://github.com/nodejs/node/search?q=POSIX
And you will find that both symbols are defined in node.gypi. From reading the surrounding code in that file, you can also deduce the conditions under which they are defined.

Related

Read and operate on a TS file using node js

I am creating a npm library where I need to read the files of the folder from where my library function were invoked from command line and then operate on those files.
By operation I mean to check if a variable exist, if a function exists, modifying variable, function,etc.
The files will be a Typescript files.
Any help on how to proceed will be great.
Seems like you need some kind of AST parser like Esprima or babel-parser. These tools can parse the content of JS/TS files, build the abstract syntax tree that can be traversed, modified and converted back to the source code.
There's a lot of useful tools available in Babel toolset that simplifies these operations. For example, babel-traverse simplifies searching the target statement or expression, babel-types that helps to match the type of the AST nodes and babel-generator that generates the source code from the AST.
It's going to be very difficult to get these answers without running the files.
So the best approach is probably to just import the files as usual and see what side-effects running the files had. For example, you can check if a file exported anything.
If this doesn't solve your problem, you will have to parse the files. The best way to do that might be to use the typescript compiler itself:
https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API

What is a .clientrc file?

You can find a mention of it here: https://code.visualstudio.com/api/language-extensions/language-server-extension-guide
however without any explanation. I couldn't find information about it by googling.
What is the purpose of a .clientrc file?
As mentioned in the comments, ".clientrc" was just chosen as an example file name.
If you google site:code.visualstudio.com clientrc, that page is the only search result. And googling site:github.com/microsoft/vscode "clientrc", all the results are about example code (and most are about that example code specifically).
The .*rc file name pattern is a common convention for application-specific configuration files. There's a baeldung article on it:
Names including rc often signify files or directories of files with code. Specifically, this code consists of commands that are meant to run when a program is executed. Indeed, that program can be an application, but it can also be a whole operating system.
Because of this, the original rc affix and extension both meant “run commands”. In particular, a widely accepted source of the term is the Compatible Time-Sharing System (CTSS)

Find the path to a library when using headless linux image

Hi I'm connected to parallella board , using only UART, I'm written and executing codes using only GNU bash, and I don't have a desktop. only that terminal connection
I'm using DevIL library in a C code, and i receive undefined reference toilInit'` etc..
so I should tell where is the path to DevIL library, what are the GNU bash instructions in order to find the /path/to/DevIL/lib/dir and DevIL lib name, I try find DevIL , and i receive no such file or directory
Try
find / -name libname
where libname is the name of your library. This will return all paths that contain a file with the name libname anywhere in your system. If you have a rough idea of the location, use that path instead of the system root / as this will make the command run faster (When called as above the first argument is telling the find command what directory to search under).
Libraries usually start with libxyz, so perhaps you should check the name as DevIL does not adhere to this convention.
You must know the library name since you will need to pass its name and location as a link option to your C compiler at some point.

Bringing in other local scripts with Component package manager?

I'm just getting started with Component package manager. I understand that I can require in other local modules by adding the module to the local key in the component.json file, but what if I don't want to treat every file as a module?
In the (very minimal) documentation for Component, it's developer TJ says that I can add any other relevant scripts (that live in the same directory) to the scripts array. And yet, on doing so, I'm unable to require or reference any of the peripheral scripts' methods from my main file.
The require method fails on trying to load in the script, and any attempt to reference the methods or variables from that script from the 'bootstrap' file are futile. My build.js shows that the script has been compiled in, but I just can't seem to figure out the correct way to reference it from other scripts...
Help?
I just thought I'd post the answer to this question so anybody with the same problem can find it quickly/painlessly.
The answer is to reference the script with a pointer to it's current directory like so:
var script = require('./script.js');
Note the ./ at the beginning of the file name.
An easy mistake to make/rectify.

Mixing typescript definition files with nodejs require over multiple files in an internal module

Are there any known issues with mixing nodejs modules (require) with typescript definition files (d.ts) multiple times over files within a module?
My scenario is that I have a module namespace per folder (much like I would in C#), then I basically compile them all via tsc to an outputted my-module.js. However I keep getting really odd errors like Could not find type HTMLElement but lots of people have pointed out that tsc includes the typescript lib file by default which contains all those types.
I have noticed a few people having odd errors when they are including the same d.ts files over multiple files which are all compiled with the --out flag to get it all into one file, so could this be causing my issues?
An example of my usage would be:
///<reference path="path/to/knockout.d.ts" />
import ko = require("knockout");
This would then be put in each file which requires knockout js, which is at least 10 files in the module i'm trying to compile currently. It just bombs out constantly saying knockout.d.ts cannot find the type HTMLElemet, Element, Document etc.
If you are using external modules (which you are if you have a top level "import" - as shown above), then you can't use the --out switch to combine multiple source files. It is a limitation that with external modules that one source file = one module. With source that is not in an external module (i.e. contributes to the 'global' scope), you can combine input source to one output JavaScript file using --out.
I have no idea about the "could not find HTMLElement" issues. If you can provide a repro (and outline which version you are using) I can take a look.

Resources