Depending on lots of npm from vscode module…? - node.js

I'm just starting out trying to integrate Ensime scala ide-support into vscode. I have pulled out some of the integration parts from my atom package https://github.com/ensime/ensime-atom into https://github.com/ensime/ensime-node.
However, when depending on this from vscode I get red squigglies that it can't be found:
However, code still build and runs just fine. I got worried. I found this:
Q: Can I use native Node.js modules with my extension?
A: A Visual Studio Code extension package contains all of its
dependencies. This means that if you develop your extension on Windows
and depend on a native Node.js module when you publish that extension,
the Windows compiled native dependency will be contained in your
extension. Users on OS X or Linux won't be able to use the extension.
The only way to make this work for now is to include binaries for all
four platforms of VS Code (Windows x86 and x64, Linux, OS X) in your
extension and have code that dynamically loads the right one.
What does this mean? I can't use fs, net, child_process and the like? Kindof need them all I think or does vscode provide all that through abstraction layers?

You do have the basic node modules (fs, etc) already included as part of the dependency of vscode itself.
Did you remember to include this module in your package.json file as a dependency?
A way to check this would be to clean your code, put it in a new folder, and run "npm install" - if everything then runs fine, you are good to go.
See this docs:
https://code.visualstudio.com/Docs/extensionAPI/extension-manifest
Be sure to also read up on the new extension authoring update in the latest version: https://code.visualstudio.com/Updates

Related

Electron without GUI

I need to create a node.js application that works in background as a web application. The app should provide some functionality for the main client's site. The application is going to be installed on many machines with differences OS, that's why I want to get rid of node.js dependency and compile it to binary.
I used electron-builder, but as I understood it depended on GUI. So, what can I do to compile the app that can work without GUI and Node.js?
How about pkg?
This command line interface enables you to package your Node.js project into an executable that can be run even on devices without Node.js installed.

How to ship an openfl desktop (windows) application

I created a haxe project using openfl. I can build and run the project on my own desktop using lime test windows.
Now how do I actually ship this project to other users?
I tried simply zipping the binary output created by running the command above. When I then unpack this zip on a different computer and start the executable file it will complain that I'm missing certain .dll files (more specifically the libstdc++-6.dll file).
Although this is not a direct answer to your question, a solution to this issue would be to compile through another software/tool, such as FlashDevelop.
For a few versions already, FlashDevelop includes an App manager feature that allows you to easily install the latest versions of Haxe, Lime & OpenFl (in an all-in-one package), and compile for all the Haxe/Lime/OpenFl targets seamlessly by just switching a value in a drop-down menu.
This allowed me to compile without any problems native C++ or Neko versions of my projects, thus embedding all the necessary files that could be zipped and sent to other computers.

What are some mechanisms to package cross-platform Electron apps in a single build?

I'm developing a desktop application based on Electron and I use electron-packager to create executables. The app uses some binary node modules such as bcrypt.
On my Mac, I package the app, targeting both OSX and Windows. The resulting package runs fine on OSX. But when I run the resulting Windows package (.exe and dependencies) on Windows 8.1 64 bits, the app throws an error (quite expectedly):
Is there any practice or tool that helps me be able to do the packaging once in any OS, even if the app depends on binary modules, and produce executables for Windows, OSX and Linux? For example, I'd like to run the build on OSX to produce executables for all three operating systems, instead of having to repeat the packaging for each platform
You should look into removing native binary requirements from your project if possible. For example the module you mention, bcrypt, has another implementation which is full JS and doesn't require native binaries: https://www.npmjs.com/package/bcrypt-nodejs
If you really need to include compiled binaries as a part of your dependencies you're probably going to have to design that part of the build/packaging automation yourself.

Does anyone know of a good set of installation instructions for Node.js?

I'm trying to get started with Node.js on a Windows machine. Yes, I found the installer on their site. That worked just fine and I can run it. However, after that there's no instructions or requirements. Some issues I ran into:
I learned that most of these cool modules need to be built locally.
I was told I needed Git installed
I found I needed Python to build modules
I discovered I needed Visual Studio to compile
Once things are built they should be executable. However, they are not natively found in the path. I discovered them under %APPDATA%\npm, but there's no mention of adding that to the PATH.
What else am I going to discover? Is there a guide to this anywhere?
Altough I might suggest you to develope node on a unix based os (Ubuntu 12.04+WebStorm is my favorite combination for many reasons I can mention) I found my self in your situation at work when Windows 7 is a must.
I found this video really helpful
Once youe have node installed on your machine (window or any other) I (and most community) would recommend you to use WebStorm as IDEA it contains every inch of support to make your development process easy and clean, mange your global and local modules and build/debug your code easily.
It sounds like you've actually installed Node.js fine, but are having problems with the packages built by people in the community, some of which use Python or a native C compiler. Git shouldn't be necessary unless you're perhaps cloning projects from a remote repository? Or maybe the packages have dependencies on projects hosted in GitHub?
Keep in mind that Node is separate from all the modules and packages available in the community, accessed through the npm registry. Node provides you the ability to execute JavaScript locally, additional APIs, and an ecosystem to build additional packages which can do, as you've said, really cool things. But each of these packages can have unique installation requirements.
Most packages have dependencies of their own, and are often installed using the npm install command. This (usually) downloads other packages from https://www.npmjs.org/, and in some cases requires compiling additional files. This might have been the issue you hit.
The other thing to keep in mind is that a lot of people might assume things are installed and available since they have it installed for them, or are running a different operating system than you. I've often found that folks will hard code / somewhere in their scripts, which cause problems on Windows based systems. This can lead to problems with the executables that are created as part of the node packages created by the community.
To better understand what Node has and what's available, I'd recommend the nodeschool.io projects. These cover some of the main areas provided by the base Node platform, and get you used to playing around with things from GitHub and npm. Maybe if you run into specific issues there folks can help more directly.

What is "node-waf" and how to get it on Windows?

What is "node-waf" for node.js and how do I get it on a Windows development machine?
node-waf is a wrapper around the build system waf to simplify building of native C++ extensions for node.js. As far as I know there's not yet a replacement for windows.
But I know that some people managed to build native extensions with Vistual Studio instead.
This repository contains a windows build for contextify, needed for jsdom. Maybe you can look at how it is built and adapt that.

Resources