Does anyone know how to get a hogan.js 3.0.0 dist file?
The files at https://github.com/twitter/hogan.js are source files that should be compiled with Node.js in order to create the distributable. My question is how to build the source files with Node on Windows, or a link to a pre-built distributable file.
The dist file is mentioned here: https://github.com/twitter/hogan.js/blob/master/lib/hogan.js#L16
Hogan uses a Makefile to create dist builds and do testing. This can be envoked by running make dist from a NIX terminal. https://github.com/twitter/hogan.js/issues/156
If you want to avoid using the Makefile, because you are running node.js from a Windows command prompt or for whatever reason, you need to create a ./dist directory in Hogan's root directory where the package.json is, then run node tools\release.js.
Make sure you've installed the dev-dependencies with npm install in the same directory as the package.json first.
Related
First of all, I am generating an electron native application using electron-builder, npm and npx.
The next commands/steps are being executed to compile and generate the electron native application:
npm run build -- --prod --build-optimizer (to compile app)
npx electron-builder build --windows (to generate an electron windows app)
Later, I obtain a myApp folder which contains:
/win-unpacked
electron-builder-effective-config.yaml
myApp.exe
My application uses the node_modules folder which contains all node dependencies used in my application.
My question is: are there any way to unpack the native application or similar and patch new changes inside node_modules?
After perform an investigation, I have discovered that node dependencies are packed in system cache inside an app.asar file which contains a dist folder with some .js files.
In developer tools:
Inside app.asar:
Are there any way to "deploy" node modules folder with the aim to perform patch operations of each package and change the code inside node modules folders?
I will appreciate any kind of help.
Asar is a read only archiv format, so you cant patch any files in the archive.
But what you can do is to disable the asar option in your build config.
So in your package.json define it like this:
"build": {
"appid": "........",
"win": {........},
"asar": false
}
if you build this, there is no asar archive anymore and you can overwrite any file...
what you can also do is using asar programatically. So you can unpack the asar archive, updating files and package new archive. See here how you can use it
Contrary to what is being said here, patching a .asar archive is totally possible. I have published a library on NPM called patch-asar that does specifically this.
May be a noob question about nodejs and typescript, consider i have src folder where all my .ts files are located, and a lib folder for compiled files.
When i commit files to ignore lib folder from .gitignore file, my question is simple :
- the other developper who is charged to pull my changes and start the production node server should compile first .ts files from source ? and then from package.json he target the compiled lib folder to run the script?
Thanks for your light
Yeah, in TS it's similiar to compiled languages- you have to compile (transpile) project before using it.
The common practice is to use CI/CD to transpile ts files and deploy transpiled ones to production.
If you want to simplify the process of running the application in development environment I recommend you taking a look on ts-node npm package
I'am trying to compile a Node.js package (github action) into single file using #zeit/ncc NPM package, but some dependencies don't get copied to dist directory.
For example my package depends on 7z-min and nightmare NPM packages. Running ncc build index.js build single file successfully and copies 7z binaries for each platform correctly but nightmare electron binaries don't get copied. Only a file called path.txt containing dist/electron.exe.
When running my github action it fail to find electron executable.
Most probably you might have not imported the package in the JS file.
I want to be able to step though my C++ code for a Node.js addon that I am making. I understand that CMake.js has the --debug option, but there is no documentation about it.
I am using the node-addon-api module, in CLion.
After months of blind debugging though the use of Errors to print variables, I have finally figured out how to attach the CLion debugger to a Node.js addon.
Create a new CMake Application configuration.
Fill in these fields:
Target: Your project
Executable: The Node binary (On Unix do which node or where.exe node on Windows)
Program arguments: Path to your JS file
Working directory: The directory where the JS file is located
Before launch: Build
Start this configuration in debug mode.
I recently stumbled on the same problem and had success creating a custom toolchain in CLion 2020.3 with CMake.js on a Linux system.
Reproducible steps:
Install cmake-js via npm install -g cmake-js. Make sure to install the package globally, so that your toolchain becomes available across multiple projects.
Create a npm project, e.g mkdir my-project && cd my-project && npm init.
Run npm install bindings && npm install node-addon-api (For the C++ wrapper).
Create a CMakeLists.txt in the root directory and paste this. Make sure to replace file(GLOB SOURCE_FILES hello.cpp) with your addon-specific cpp and header files.
Open my-project in CLion.
Go to Settings / Preferences | Build, Execution, Deployment | Custom Build Targets and click + to add a new target.
Go to Build | Tool Settings | Program and set it to the cmake-js binary that you downloaded in the npm directory where you keep your global packages.
Set the arguments to compile -D and set the working directory to the root directory of my-project.
Go to Clean | Tool Settings | Program and set it to the directory where you keep your cmake-js binary. Set the arguments to clean and set the working directory to your project's root directory.
Add a new Run Configuration and specify the Toolchain you just created in the Target field. Point the Executable to your node executable and add the .js file where you import your native addons to. Set the working directory to the current directory as well. Now, you can build the target, and also debug the N-API layer of your native code, too!
I have a project setup that is as follows:
workspace
└cache
└node_modules
└gulp (and gulp-plugins, express etc.)
└nodejs
└node.exe
└project1
└gulpfile.js
└project2
└gulpfile.js
Now I want to execute the gulpfile in the project directories:
set NODE_PATH='C:\workspace\cache\node_modules\'
cd C:\workspace\project1\
C:\workspace\nodejs\node.exe C:\workspace\cache\node_modules\gulp\bin\gulp.js watch
and I get the following output:
[12:06:04] Local gulp not found in C:\workspace\project1
[12:06:04] Try running: npm install gulp
In both project folders the gulpfile is similar and uses a similar set of plugins. I'd really like to have the dependencies only once (because potentially I have up to 25 projects sharing the same node_modules).
Is this setup possible, or does the seperate project directories need to have their own node_modules folders?
Gulp requires you to have both a global installation as well as a local one. So you need to have your Gulp relatively to your Gulpfile. If your package.json would be located in workspace and your node_modules would be in workspace/node_modules everything would work fine because of Node's search tree, but if you can't move them, the only way to make it work is to "fake" the node_modules folder.
You can do this by creating a symbolic link.
Here's on Unix/Linux/Mac:
ln -s ../cache/node_modules node_modules
Here's on Windows
mklink /D node_modules ../cache/node_modules
(the latter one might work different, I'm not on a Win machine)
You could also try pkglink
From description:
Space saving Node.js package hard linker. pkglink locates common JavaScript/Node.js packages from your node_modules directories and hard links the package files so they share disk space.
Edit: ddprt
On Windows
mklink /D node_modules "C:/fullPATH/cache/node_modules"
you could always use the '-g' parameter with npm install 'package-name', so as to make the module available globally to access across different projects.
See the following links
what does the "-g" flag do in the command "npm install -g <something>"?
How do I install a module globally using npm?
https://docs.npmjs.com/files/folders
Packages are dropped into the node_modules folder under the prefix. When installing locally, this means that you can require("packagename") to load its main module, or require("packagename/lib/path/to/sub/module") to load other modules.
Global installs on Unix systems go to {prefix}/lib/node_modules.
Global installs on Windows go to {prefix}/node_modules (that is, no
lib folder.)
Scoped packages are installed the same way, except they are grouped
together in a sub-folder of the relevant node_modules folder with the
name of that scope prefix by the # symbol, e.g. npm install
#myorg/package would place the package in
{prefix}/node_modules/#myorg/package.