How to build Prisma Windows electron app on Linux? - npm

What we want to achieve is to build linux and windows installers for our Electron app on our (Linux) build server.
After installing Wine, this basically works, except for Prisma:
i.e. Prisma relies on OS-specific binaries - thus, we must have the correct binaries available for each platform.
Prisma Query engine / Prisma Client
This part works: we set the binaryTarget to our target platforms: binaryTargets = ["windows", "debian-openssl-1.1.x"].
When we now generate the client (prisma generate), the target dir (node_modules/.prisma/client/) contains the query-engines for linux and windows: libquery_engine-debian-openssl-1.1.x.so.node, query_engine-windows.dll.node
Prisma Migration Engine
i.e. in package.json we only specify the prisma dependency and npm will only install the binaries for the current OS in node_modules/#prisma/engines/, i.e.: libquery_engine-debian-openssl-1.1.x.so.node, migration-engine-debian-openssl-1.1.x
How can we get npm to install both migration Engines (i.e. for Windows and Linux)?

set the PRISMA_CLI_BINARY_TARGETS accordingly: e.g. PRISMA_CLI_BINARY_TARGETS=darwin,rhel-openssl-1.0.x npm install
then start npm install
and now the binaries for all specified operating systems should exist in node_modules/#prisma/engines
in my case, this did not work initially
after deleting node_modules/#prisma/engines and starting npm install again, it worked

Related

How can I force node to download packages for a specific architecture?

Context on my setup:
I am using Mac M1 and am running windows through parallels.
When running npm install the default package that is being downloaded is ia32 architecture and as far as I know parallels does not support x64 windows however x64 programs can be run on the ia32 architecture with no issues.
The package I am trying to download is from a custom repository and has no ia32 package build.
I am aware of commands such as npm install --arch=x64 and this works great however I am trying to bootstrap using lerna and would like to override the downloading dependencies step in lerna to use x64 packages
Is there a way to force node to install x64 packages through modifying the package.json or through another means?

Override Platform for Yarn 2 install

I have a number of docker containers which have a volume shared with my local filesystem. I am trying to install the package esbuild, which has different versions for linux and darwin OS's. When I run yarn install locally, it installs the wrong package version, and ignores the correct version, no matter how I declare it, as it detects my darwin platform and assumes I don't need the linux version:
esbuild-linux-64#npm:0.14.14 The linux-x64 architecture is incompatible with this module, link skipped.
I can connect to the container and run the install from there, and it installs the correct esbuild-linux-64 version in that case, but the install/build runs prohibitively slower because the container is much smaller than my machine.
I have looked through most of the Yarn documentation, and it seems they got rid of a couple of methods in Yarn Classic which allowed you to override the platform, or at least ignore incompatible package detection.
In Yarn v2, there is a new config setting, supportedArchitectures:, set in the .yarnrc.yml file, but it seems the yarn link step still ignores any incompatible packages which were included in supportedArchitectures.
Thanks for any help!

Local versus global packages for Angular development

When developing with Angular, one can
npm install
to install packages locally, or
npm install -g
to install them globally. I am wondering what are the implications of each practice. And what happens if a particular package is installed both ways, perhaps with different versions? Which one will my Angular app use?
From there https://www.quora.com/When-do-I-install-a-package-locally-or-globally-in-NPM
In general, the rule of thumb is:
1. If you’re installing something that you want to use in your program, using
import { 'whatever'}, then install it locally, at the root of your project.
2. If you’re installing something that you want to use in your shell, on the command line or something, install it globally, so that its binaries end up in your PATH environment variable.

Gulp install on Windows (Npm issue)

I'm trying to install Gulp for my Angular UI project and I'm a bit surprised by the fact that it won't install due to it's dependencies. So, node installed fine, but npm.js refuses to install due to file path too long error. My folder structure is 75 characters long, of the 260 available characters, that leaves 185 characters for npm to use. Am I missing something here, or do the npm authors expect me to fire up a linux box for my UI? (A deal breaker)
Update:
What is the best way to install gulp as a dependency for my Angular UI project? (My goal is to ultimately have gulp become part of my TFS CI)
Ignoring your path length problem for now (you may want to split your question), as far as how to get gulp installed, you just need to include it in your package.json file as a dependency.
You can do that by running npm install --save gulp
However, that does need npm installed first.
The easiest way to do this is to download and install Node from:
https://nodejs.org/en/download/
This will install Node and npm globally, which should avoid your path length problem and in my experience is the standard approach (I've not worked with TFS, but all other CI pipelines I've worked with support Node via a container image or build option/step).
If you dont want to manually install Node, you can use something like Chocolatey to install it automatically (you can install Chocolatey from https://chocolatey.org/ and then you can run choco install nodejs from your command line).

Apache Cordova VS Community 2015 - Run Dependency Checker Fails

Apache Cordova Dependency Checker fails in VS Community 2015. It was previously working on this computer until I ran several VS and 3rd party tools updates. Here's what I've done to try to resolve the issue:
Installed VS / Apache Cordova (no error messages displayed) following article https://taco.visualstudio.com/en-us/docs/install-vs-tools-apache-cordova/
Run Apache Cordova Dependency Checker but VS freezes with the error message - VS 2015 has stopped working, windows will try to restart the program.
I restarted VS and cleared Cordova cache, checked environment variables (all good), then tried Apache Cordova Dependency Checker with the same freeze result.
I tried to update Apache Cordova with the fix option (no error messages) but received the same freeze results.
I completely uninstalled Apache Cordova, 3rd party tools (following article https://support.microsoft.com/en-us/kb/3016536), and VS community and then reinstalled them (no error messages) but received the same freeze results.
I installed Apache Cordova on another computer and the dependency checker phonegap app... worked. Unfortunately that's not a computer that I have access to.
What else can I do to resolve the Apache Cordova installation issue?
Thanks for any help,
Mike
Since my original post, I've had to resolve Visual Studio, Ionic, Cordova, Phonegap, plugin... environment issue several times. I've found the below works best:
Ensure platform matches plugin requirements, see platform in config.xml e.g. 6.1.1
Uninstall, reinstall latest jdk (adobe)
Clear MEF Cache - download the tool and follow instructions
Download/install latest node.js
Run the following from the command line:
Clear cache: Npm cache clean
Install latest npm: npm install -g npm
Uninstall cordova: Npm uninstall -g cordova
Reinstall cordova: Npm install –g cordova (note, this took 5+ tries to complete without errors. No other changes were made between runs. Not sure
why. Found others complaining about the same issue.)
Remove Android platform: Cordova platform remove android
Install Cordova platform add android#6.X.X (Note, as of 4/20/17 cordova and android compatibility issue. Build error - unable to find installed version of gradle. resolved by running (npm install -g cordova#6.4.0) and (cordova platform add android#6.1.2). Addt'l build errors, resolved by updating components in Android SDK Manager)
Uninstall/Reinstall plugins from the command line. For example:
cordova plugin remove phonegap-plugin-push
cordova plugin add phonegap-plugin-push variable SENDER_ID="YourID#"
npm install bower -g
Restart Visual Studio - Verify plugins were installed via config.xml
Install Ionic:
npm uninstall -g ionic
npm install -g ionic (note: to install specific version, npm install -g ionic#2.2.3)
$ ionic platform add ios
$ ionic platform add android (note: redundant, already added above)
I recommend putting as much of this as possible in a batch file with a pause between commands. Verify each command was successful, if not press ctrl+break at the pause to term the batch file early. The batch file is an easy way to restore your environment when everything breaks again. Stuff happens!
I also started using a VM (oracle virtualbox) for my development environment. That way I can backup my environment before making changes and easily restore. Don't forget to upload to GIT on a daily basis. GIT and VMs are my lifesavers.
Cool NPM commands:
npm list (lists all installed packages)
npm prune (removes packages not depended on by your project according to your package.json)
npm outdated (tells you which installed packages are outdated with respect to what is current in the npm registry but allowable by the version definition in your package.json. Make sure all up-to-date)
Please feel free to add/make suggestions to the above list.
-Mike