How to set WebStorm for node.js? - node.js

I'm developing for ReactNative because I developer of front-end. (Using WebStorm)
But I got a job of server of node.js. (I want to using WebStorm too)
A lot of expression is occurrence like this.
I just clone some node.js project and open the project in WebStorm.
How do I set WebStorm for node.js?
(if I change setting for node.js, I wish ReactNative project is not changed.)

Please make sure that JavaScript Language Version (Settings/Preferences | Languages & Frameworks | JavaScript) is set to ECMAScript 6; looks as if ESMAScript 6 syntax (arrow functions, etc.) can't be parsed correctly

Related

is it required babel configuration when I use vite in place of webpack

Recently I was create react app using vite , it is lightweight , less config and fast then compare with webpack . now my question is , is it required bable configuration in Vite project
No, vite does automatic syntax transforms but it only targets browsers that support es modules (firefox & chrome started supporting it around 2018). If you want to support new js features in older browsers you need to add polyfills though. You can read about the exact behavior and how to support even older browsers here.
I think that question need more information about that topic.
Vite.js uses the built-in JavaScript support of the browser, so you don't need to explicitly configure the JavaScript version in Vite.js itself.
When I said Vite.js uses the built-in JavaScript support of the browser, I meant that Vite.js relies on the JavaScript engine of the browser to interpret and run the JavaScript code in your application. The JavaScript engine is the component of the browser that executes JavaScript code. When you visit a web page that contains JavaScript, the browser runs the JavaScript code using its built-in JavaScript engine. This means that the version of JavaScript that is supported by your application is determined by the version of the JavaScript engine that is built into the browser. In the case of Vite.js, the JavaScript code in your application is not transpiled or otherwise modified before being run by the browser. However, if your application uses modern JavaScript syntax that is not supported by the target browsers, you will need to transpile the code to an older version of the language that is supported. In that case, you can use Babel.
No, it is already setup on the background. However if you'd like to adjust Babel's config you can do it. Read the docs here: https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md

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?

IntelliJ IDEA can't find KoaJS methods

Currently, IntelliJ IDEA reports that KoaJS's methods are undefined.
Does anyone use intellij idea with KoaJS and have intellisense/code completion working properly?
To get Koa methods resolved, please try using Koa typescript stubs: download https://github.com/DefinitelyTyped/DefinitelyTyped/blob/types/koa/koa.d.ts file and set it up as a JavaScript Library (Settings | Languages & Frameworks | JavaScript | Libraries, Add...)

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.

Is there any standlone gui module for node application [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to build a code editor in nodejs. There is option like using an express server to show editor and to execute code in backend. But that would require a browser. So I am looking for node modules that can provide standalone gui for windows platform.
There are a couple of different options, depending on how you want to proceed.
Option 1:
Use something like QT or GTK bindings to make a more traditional GUI application. These options generally are just Node bindings to the C/C++ API that GTK and QT expose. See node-qt and yue. Although these seem to not be actively developed.
Update:
You can take a look at NodeGUI: https://github.com/nodegui/nodegui
NodeGUI is a javascript library for building cross-platform native desktop applications with JavaScript and CSS like styling. It uses Qt under the hood and works on Mac, Linux and Windows.
It also has a react based renderer called React NodeGUI which is like React Native but for desktop: https://github.com/nodegui/react-nodegui
Option 2:
Use a framework that takes HTML, CSS, and Javascript and bundles it into a standalone HTML5 app. There are a bunch of frame works out there that do this. Examples include node-webkit and AppJS among many others.
I recommend using an HTML/JS/CSS Framework
Option #1: Electron by GitHub.
Website | GitHub Repo | Releases
It's easier than you think
If you can build a website, you can build a desktop app. Electron is a
framework for creating native applications with web technologies like
JavaScript, HTML, and CSS. It takes care of the hard parts so you can
focus on the core of your application.
Option #2: NW.js (previously known as node-webkit).
Website | GitHub Repo | Releases
Call all Node.js modules directly from DOM/WebWorker and enable a new
way of writing applications with all Web technologies.
Electron and NWJS Pros:
AppJS is officially deprecated
Electron is similar to NW.js but newer, more popular and has a bigger community and updates more frequently. I recommend it.
NWJS always uses the latest Versions of Chromium and Node while Electron takes more time to catch up.
NWJS supports [JavaScript Source Protection][1] by compiling it to V8 native code. Electron does not.
NWJS have a Legacy release for Windows XP and Mac OS X 10.6 support.
Electron and NWJS both use MIT license.
You can compare the contributions to electron with NW.js
Electron and NWJS Cons:
there is no out-of-the-bag run-time solution currently, so you'll have to ship it with your code (~50MB compressed and +100MB uncompressed) or find a way around it.
depending on your app, Electron/NWJS might considered an overkill especially since its startup time is less than ideal, just something to take into account.
no native look, you'll have to create your own UI elements using CSS or using some framework.
Option #3: DeskGap.
Website | GitHub Repo | Releases
DeskGap is a framework for building cross-platform desktop apps with
web technologies (JavaScript, HTML and CSS).
To enable native capabilities while keeping the size down, DeskGap
bundles a Node.js runtime and leaves the HTML rendering to the
operating system‘s webview.
Lightweight since the webview is provided by the operating system.
The API is still quite limited (pretty much a work in progress).
Requires new OS versions.
Apart from the other answers here:
You can take a look at NodeGUI: https://github.com/nodegui/nodegui
NodeGUI is a javascript library for building cross-platform native
desktop applications with JavaScript and CSS like styling. It uses Qt
under the hood and works on Mac, Linux and Windows.
It also has a react based renderer called React NodeGUI which is like React Native but for desktop: https://github.com/nodegui/react-nodegui
Also, its under active development.
I recently discovered https://github.com/yue/yue and I'm having nice experience. It's lightweight, has descent packaging support (and even react/JSX support) and is truly native with decent webview, portable and easy to build target platform's.
Although it seems discontinued I found this project unique, it's really native with options to add a descent webview. I retake some PRs and forked it and I'm adding TypeScript types and documentation since it's really clean/straight forward API, easy to build target platform files. this is my fork although I would like/searching for other users adding missing parts: https://github.com/cancerberoSgx/node-gui . The cons is that it implements node.js event loop so you must use yode (node.js fork) in order for promises and asynchronous code to work well with the GUI code.. m
I wonder if others have experience with this library or forks.
Answer specific to your question may be NodeGui (powered by Qt5, NodeGui-React)
There are many other options. I'm listing a few options below,
electron (Lets you write cross-platform desktop applications using
JavaScript, HTML and CSS, based on Node.js & Chromium)
carlo (Requires Node & Google Chrome to be installed on the system to
run)
NW.js (Similar to electron, provides Source code protection)
DeskGap (bundles a Node.js runtime and leaves the HTML rendering to
the operating system‘s webview)
Proton Native (does the same to desktop that React Native did to
mobile, based on https://github.com/parro-it/libui-node)
For more, you can use my github repo electron-alternatives to pick a cross-platform desktop development option.
Recently also Node-gir may be worth a look: https://github.com/Place1/node-gir
Allows to use Gnome/Glib/Gobject-based libraries from Nodejs. Will allow you to use GTK+.

Resources