How can I create dynamic routes in electron? I am confused because electron doesn't make use of URLs if am not mistaken
You have to use build in packages such as express. The command to install it is: npm install express --save (to install locally in the project directory) or npm install express -g to install it globally.
Related
I am new to Electron (Atom-shell), and I am trying to load a NodeJS plugin into the application I am building, but I don't know how. The documentation is not clear on that.
For instance, I am trying to use sqlite3 plugin in my app, I used npm install sqlite3, and it was successfully installed. But the application throws and error when I try to call it var sqlite = require('sqlite3'). Are there any further steps I am not aware of ?
Thanks.
For pure JS (i.e. not native) modules you need the following:
Have the module listed in your package.json dependencies
Let electron know where to find the module (e.g. export NODE_PATH=/PATH/TO/node_module)
The first requirement is obvious and the second has its roots in this issue.
For native node modules (such as sqlite3) which use C++ bindings, you need to build them against electron headers to work. According to electron docs, the easiest way to do that would be:
npm install --save-dev electron-rebuild
# Every time you run npm install, run this
./node_modules/.bin/electron-rebuild
To install the npm modules correctly you should go into the folder of your electron app and install the module via npm.
npm install --save sqlite3
The flag --save is important, because npm will install the module inside your app.
Afterwards the require should work.
I am trying to install express module install, but the issue is that after installation I am still unable to use express.
What I've done:
Install express using cmd - npm install -g express
For some reason it's not installing globally.
Help?
You might want to use the following:
npm install -g express-generator
Source: Issues with installing Express.JS in Windows 7
In later versions of express comand line was migrated to a separate module: express-generetor
use
npm install -g express-generator#3
and could use the express command
For example I installed express with global (-g) parameter. In node.js/node_modules folder express doesn't exists.
I tried to install it without global parameter and it works perfectly.
How to install it globally?
Thanks.
Installing modules via npm with -g is only for modules that provide command-line utilities, not for making any ordinary module accessible from anywhere.
So if you are looking to use the command-line express project generator utility/command, you need to use npm install -g express-generator instead.
If you want to require('express'); in your application, then you need to install express with npm install express.
I'm having trounble with installing express. After I do npm install express, express is still not visible. I.e. I'm unable to do express appname. I'm running Win7. What is done incorrectly?
UPD. I'm following this tutorial
since express 4.0 the CLI tools are not part of the main express package anymore. if you want to have the generator you have to install it separately:
npm install -g express-generator
see here
If you want to run the :
express appname
command, you should install express the following way :
sudo npm install -g express
or just:
npm install -g express
if you are not on a UNIX system. Otherwise if you already did an :
npm install express
you can run this command:
./node_modules/express/bin/express appname
from your project's root directory.
I am really new at node js. I was wondering if any one can tell how to install express framework and stylus in a directory which i want. I have installed both globally but cannot find a way to install it locally.A simple suggestion will suffice.
> cd myFolder
create a README.md
> npm init
fill in details
> npm install express stylus --save
You'll then have a express and stylus installed locally and contained in your package.json