WebStorm node configure balloon - node.js

I am using WebStorm for a Node.js project, and I keep getting a warning balloon which is rather annoying, and I can't remove.
I have tried various things to remove, but have not been successful. What I have tried :
Files-> Settings-> Notifications -> I have disabled balloon notifications.
Files -> Settings -> Languages & Frameworks -> Node.js and NPM
The configuration of the node modules does not work here either.
Anyone know how to remove the balloon?

Just guessing, but it might be easier just to configure Node.js sources and add the libraries.
For Webstorm 9+:
Try selecting the 'Download from Internet' option instead Or determine what your source root directory should be (The default here is not correct for you).
Then, one or more of the following:
A. Right-Click in the editor panel > Use Javascript Library > Node.js
Globals
B. Repeat A, but select Node.js Core Modules

Related

How to enable Node.js code autocompletion in VSCode?

I have installed Visual Studio Code and Node.js and both basically work, but autocomplete is not (completely) working. If I type 'console.' I do indeed see a list popup. Likewise if I do:
const http = require("http");
http.
But if I simply type 'process.' I don't see anything. In fact as soon as I type '.' Code autocompletes 'process' to 'ProcessingInstruction'. I was expecting to see argv pop up, along with all the other stuff you see if you type 'process' at a Node prompt.
Here's what I see when I type 'console.':
Yay -- it works!
But here's what I see when I type 'process.' (I have to change the autocompleted 'ProcessingInstruction' back to 'process'):
Boo -- it doesn't know 'process'! :(
You will need to tell VS Code about the types in Node JS (as you hit at yourself in the comment). To do this you can install the types for node running the following command (assuming you have already run npm init):
npm install --save-dev #types/node
It will install the types for Node JS, which VS Code automatically picks up and you'll be auto-completing all Node JS-specific things going forward. You don't even have to restart VS Code.
As you are adding more dependencies to your project (if you will be doing so). Many of them have a #types/X package as well (if they don't have the already included in the package), which will allow autocomplete as well.
Per Microsoft's Documentation: https://code.visualstudio.com/docs/nodejs/working-with-javascript
IntelliSense for JavaScript libraries and frameworks is powered by TypeScript type declaration (typings) files.
Automatic type acquisition requires npmjs, the Node.js package manager, which is included with the Node.js runtime.
In my situation, I do not have npmjs installed and that's why automatic type acquisition fails.
*Edit, that is, after installing npm, my autocomplete starting working successfully for node related hints.
If you are using pure javascript for your node app, when including the required modules, they should be defined with single quotes instead of double-quotes. If you were using a code formatter extension like "Prettier" for instance, it adds it by default before the IntelliSense, then you would have to update your settings to use single quote.

Angular + Electron app: query web API or DataBase according to deskop or web mode

I would like to build an app using Angular + Electron. My app should be able to run both on desktop and browser platforms. I'm considering to use angular-electron starter kit (but I'm open to other possibilities).
What concerns my is the way I read and write data. The data must be stored in a MySQL database. Ideally I would like to:
make the app call an api when NOT running on Electron (browser mode)
make the app query directly the mysql database when running on Electron (desktop mode)
I know I could check for window && window.process && window.process.type to let the app understand wheter running on Electron or not, however I'm a bit concerned about how to handle this. Also because I probably need to import node packages like mysqljs but ONLY in the desktop mode.
You can simply pass in different environment files in Angular during build this allow you to control the environment variables so that you can tell that it is a web app build or an electron app build.
https://angular.io/guide/build
EXTRA
But if you are importing binary packages this is where it gets tricky. I dont think there is a clean way for you to do conditional imports. I did not manage to find a way to do it cleanly and sort of maintained another repository for all my services that needs to import binary files.
To import the binary files you will also need to edit some webpack settings to tell angular to not compile/include the binary files during the build process so that you can use you librarys like mysqljs that require binary files. There is also some settings on the electron end to make binary files compatible for different platforms ie Windows, Mac , Linux. Basically it is really a pain to do it.
Link to how to edit webpack settings for angular 7+
https://github.com/manfredsteyer/ngx-build-plus
I will totally suggest you not to do it unless you really have a very good reason that you need to use these libraries.
EDIT 10/1/19
Okay I was referring to the MySqlJs but it seems like it does not have native modules modules. Native/binary modules basically means javascript code that relies on c++ compiled binaries(Or any native language like rust...).
For my case I was using the grpc modules which has a native dependency. Had to switch to grpc-web in the end.
I will add some footnotes here if you ever need them
https://electronjs.org/docs/tutorial/using-native-node-modules
Node.js / npm - anyway to tell if a package is pure JS or not?

How to run ElectronJs without a UI?

As well as a UI, I'd like users to have the option of passing in command line options to my tool and for it to output the response to the command line (eg manually or in cron).
Even without creating a window, the UI gets going (eg taskbar on the mac), and on a linux back-end server with no UI libraries it crashes completely.
Is there a way I can avoid having to ship two apps separately, and also more annoyingly using electron to package up one exe, and something like pkg for the other?
Thanks!
You can use a bundling tool like EncloseJS to wrap your Electron application. This would allow you to write a CLI interface. You would then need to move the code that does the actual work to a shared library that both Electron and your CLI can use. You could then introduce a --headless flag that would simply not start the Electron app, while omitting the flag would start the app as usual.

How to make IDEA recognise keywords from Jasmine Node.js package?

I've got an IDEA 14.1.2 project using the Jasmine Node module for testing. Unfortunately IDEA doesn't recognise Jasmine function names like beforeEach, describe, it and expect, even though everything seems valid (the tests run fine). That is, when hovering over any of these I get a message like "Unresolved function or method function_name()", and when Ctrl-clicking I get the message "Cannot find declaration to go to".
Relevant settings:
In Languages & Frameworks → JavaScript → Libraries the following are checked:
Node.js v0.12.2 Core Modules (type Global)
HTML (type Predefined)
HTML5 / ECMAScript 5 (type Predefined)
Node.js Globals (type Predefined)
In Languages & Frameworks → Node.js and NPM (NodeJS JetBrains plugin 141.712):
the Node interpreter is set (it's in a subdirectory of the project),
"Node.js v0.12.2 Core Modules is set up", and
under Packages "jasmine" is listed as version 2.2.1 (latest).
Maybe I need to index internal Node modules, but I don't have the relevant check box in Languages & Frameworks → Node.js and NPM. Is this not available in this version of the plugin?
I've tried invalidating caches and restarting.
You need to add a TypeScript definition file as described here.
Go to Project Settings > Languages & Frameworks > JavaScript > Libraries, click Download, select Typescript community stubs from the combobox, choose jasmine and click Download and Install.

How to import existing node.js module into Intellij IDEA?

I have an existing Node.js codebase, forked from GitHub. Now I want to import it to the Intellij IDEA 13 (ultimate version, which supports Node.js). When I simply try to import the project from the root folder of my existing code, IDEA doesn't add the 'lib' folder, where all the sources are. It should be simple, but I cannot figure it out. Any hints?
Well, I've figured out a workaround, but not sure if it's the best solution. One can just create a new project of type "Web", and point it to the directory containing the module's sources. Then IDEA understands the whole structure, and you can create run configurations with Node.js.
In order to get additional Node features, like Intellisense for standard Node APIs, you'll still want to configure the project to be a Node project:
Open the Preferences window
Click Languages & Frameworks → Node.js and NPM
In the section Coding Assistance you'll see if Node.js Core library is [not] enabled. If it is enabled, there's nothing more to do. If not click the Enable button
Leave For the whole project checked, and click Configure
The text should now change to Node.js Core library is enabled.
Another workaround:
If you have a version controlled Node app with no local changes, you could also create a new project of type "Node.js and NPM", point that to the directory. Then just use any standard settings.
After the project is created, you can just revert the files overwritten by IDEA (e.g. app.js and package.json), delete any new directories and files, and you will get the additional Node features in your project.
Intellij 15 Professional Edition:
Import a new project -> Select the base folder of the project -> choose import form existing source.
When Intellij is done it wont look correct so do the following:
1) Project Structure CMD + ;
2) Go to Modules
3) Add a new module and select Node/Npm (if you dont have it then add a new plugin)
4) Point the source of the project to the base folder and click apply.

Resources