Plesk JXcore fails installing NPM Modules - node.js

When trying to add a Node Module over the Plesk JXcore Interface it fails with the message.
I can't even access the jx command over SSH.
error: Cannot install sails module. Wrong user id of the command.

Today, early morning, new version of JXcore support Plesk's extension was published: 0.2.0.
Among many things there are some improvements related with NPM modules installations, also your case with "Wrong user id of the command" was taken care of. This wasn't a bug actually. Rather a result of redundant permission check and you were the first to encounter this.
Also there is a new feature which allows to enable/disable JXcore support for entire subscription or all of them at once.

Related

How can I run "msnodesqlv8" on a computer without internet

I have a Node.js API on a Windows computer without internet access and I need to access data from a Microsoft SQL Server database. I have the module "mssql" however I need to use Windows authentication. I found online that this method requires the module "msnodesqlv8," however when I install the module on an internet-connected device and then move the files onto the non-internet device, the module won't run. The error I receive when I run the API indicates that the module needs to be rebuilt. Whenever I run "npm rebuild," the build attempts to install the dependencies - which of course is not possible without internet.
To try to circumvent this issue, I removed the dependency list prior to rebuild, but the rebuild still snags trying to install "safe-buffer." I don't know where this install is getting triggered. When I search for "safe-buffer" in the project, no references to "safe-buffer" are found. My assumption is that a dependency is trying to use it and I have not skimmed through every dependency yet.
I also tried packing the "msnodesqlv8" module, then installing it from the .tgz file, but this produced the same errors.
One avenue I have not yet tried is packing the module on the internet device, then transerfing the .tgz file.
Any recommendations would be awesome - I am blocked until I can solve this issue.
I was able to solve this problem by downloading a prebuild from the Github releases. I noticed in the stack trace of the rebuild that the process was accessing a specific build from this link, so I moved it into the "prebuilds" folder where it was expecting it, and the module powered up on the next rebuild.
This process has to be replicated on every device, from workstation to servers, but it works. Just make sure you download the build that matches your system.

is there a safe way to compile an electron app (with out npm security problems)?

i recently built an electron app using node js , html ,css , js
and have been wanting to compile it ive npm installed all options ifound (packager,build,forge) but npm says all have security issues is there asecure way to compile? (compile for windows)
most of the security vulnerabilities are mostly in "build" packages, things that are run during compile time only, and not when the electron/nodejs app is in use, only when it's built/minified/etc, but they are not included in the final product.
Then also are most of those security vulnerabilities usually highly hypothetical, with a high threshold of prerequisites for the weakness to occur.
If you wish to be certain, read the security risk descriptions, what is required, and evaluate if it applies to your system, if it's in a build time package, or a runtime package, and what kind of vulnerability it represents.
if there is a vulnerability in a package that gets included in the app, and it is one that you need to fix because it would pose a serious threat to your end users, check the repository for the package, to see if someone already submitted a pull request for a fix that hasn't made it to the main branch, and merge that into your version that you use.

Using RFID Reader on Node JS

I'm working for a public library in my town, and I have developed a web application to handle the borrowing process and other administration problem. A few years ago, the library bought and attached the books in the library with a RFID tag, and with it, also bought a RFID Reader to be used in the borrowing process, and a RFID Sensor Security Gate, to prevent the books from being taken out without proper administration process. For the RFID Reader to be used, the vendor gave me a JAVA applet to connect the RFID Reader to my web application, as it's not possible to access a device from the web with just Javascript or JQuery.
Currently, the library is asking me to develop a kiosk application for the library's self service center. I currently developing the kiosk application with Node JS, and I managed to create the user and password authentication with native Javascript and AJAX function.
However, problem occured when I tried to use the RFID Reader to detect the books. I tried using some modules called node-hid, but everytime I run the application, it gave me an error message.
I used:
Windows 10
Node v10.16.3
npm v6.9.2
Electron v5.0.6
Some poeple in the forums recommended to rebuild and reinstall the module and the node, but it's not working for me. Others told me to downgraded the Node or the npm using nvm, but from what i read, nvm only worked for Linux. Honestly, I'm still new in Node JS, and I'm a little bit confused: regarding the error message above, which one is actually the problem? The Node version, or the npm version?
Struggling, I tried to forget about using modules about RFID, and start from the scratch by detecting devices connected on USB first, so I use serialport module, but the same error persist.
I expected to be able to read the books' ID from the RFID tag, and rewrite some blocks in it to prevent the alarms from the RFID Sensor Security Gate goes off.
Any supports regarding the error above, or a recommendations to use another module will be appreciated. I'm at the end of my rope here.
I know this is a bit late but I'm putting it here just in case someone passed by it.
You are getting this error because you are using a native module which is ok for node, but because electron is a modified node, so in order for thhat to work: you need to rebuild for electron instead:
Add the electron-rebuild package
npm i -D electron-rebuild
Remove the node-modules folder, as well as the packages-lock.json file.
Run npm install to install all modules.
Run ./node_modules/.bin/electron-rebuild or .\node_modules\.bin\electron-rebuild.cmd for Windows to rebuild everything.

How could I download many NPM modules without npm install?

Okay, so I get it that I might be looking for a totally unexpected behavior.
My current company has nothing for me to do for a few weeks, so I would like to start a side project. The problem is, the firewall is really strong here, so I cannot download anything with Git or Npm. I also am not allowed to do any request to the IT support, since I am not in my company's office but some offices owned by a client (that applies said strict policy). In short, I am stuck with firewall and proxy policies that I cannot modify.
I may download a module's zipped archive through the browser, and install it from there. However, it has multiple dependencies, that themselves have dependencies, and so forth. And since I cannot run npm install to retrieve the dependencies, I'm stuck.
I saw multiple possible solutions in order to solve those dependencies issues:
make NPM run all requests and downloads through the browser, since browsers are allowed to access to the network. I don't see any options for that so far.
Download all required dependencies as tarball and step-by-step install each of them. Because of the potential number of dependencies being huge, I am looking for a huge bulk of modules commonly used to download once.
Most solutions I find make the assumption that I may use npm install properly, while my proxy doesn't allow it.
I wouldn't like to spend days on Chrome's built in game. Any idea?
maybe you can create the project somewhere else, and then "import" it on your office local machine:
npm init
edit package.json with your dependecies
npm install
put everything on usb stick and put it on your local computer at work.
or
send an archive of the code via email and download the tarball from email at office.

How to bundle a third party binary with Electron?

I am still new to the electron ecosystem and desktop development in general but what I wish to do is to interface with a third party, open source application that comes bundled in with my software. First, I am unsure on what the package options to distribute should be. Is it customary to have two downloads, one for users that already have the third party binary installed, and another one that includes it? Also how do I go about actually packaging, and installing the binary? Should this be an option on my package.json? What kind of script should I execute? Are there any npm modules to facilitate this?
edit - is it possible to invoke npm from my main.js even though a user has not previously installed node? I know node is bundled with the electron package but is npm too?
-The binary in this case is PostgreSQL
There are a couple of options coming to my mind.
Bundle a 3rd party installer w/ your app. This is what I did recently. On the first run I check if the service that I need is installed / running and if not I call the 3rd party installer / start it. When the installer quits I simply app.relaunch() and start consumig it. Of course you'll need installers for each platform you plan to support. And you'll have to figure out ways to check if the software is installed (properly) for each platform.
Bundle binaries w/ you app. Of course you can bundle pretty much anything w/ your electron app. Again, you'll need binaries for each platform you plan to support. And of course they shouldn't be linked to anything that the default user doesn't have on his machine like SDKs and additional headers ...
Less comfy but you can alway add some start-up message or before-download massage telling the user that he needs software xy in order to run your application.
Derivate of 1/2: Download required stuff on demand. For your example this would mean checking the user's OS and arch and then just download the required installers or binaries if available. You could also build the stuff on the user's machine although this probably being the worst/biggest/most complex solution.
Then there's things like https://www.npmjs.com/package/pg - you should always check npm if someone already built what you need ;)
I'd recommend using the great electron-builder which makes bundling stuff w/ your app a piece of cake.
Feel free to comment if you need more intel.

Resources