Getting error while Installing Cordova plugin - node.js

I am trying to add this plugin to my app: https://www.npmjs.com/package/cordova-pdf-generator
I installed NPM as instructed in https://blog.teamtreehouse.com/install-node-js-npm-windows. Then opened command prompt window and went to my app's folder. later i ran below commands in command prompt "npm install cordova-pdf-generator".After that ran this: "cordova plugins add node_modules/cordova-pdf-generator"
While running cordova plugins add node_modules/cordova-pdf-generator i am getting cordova.js script error.Please help me!!
Thanks,
Raghu

Those instructions seem... odd. After installing npm, you should only need to make a call to:
cordova plugin add cordova-pdf-generator --save
This should install the plugin from npm to your app, and add a line to your config.xml with the plugin info.
EDIT: thinking about the npm stuff some more, it looks like the author did some weird stuff to archive it. So... here's one way to get the plugin working. You've probably already called:
npm install cordova-pdf-generator
So that means you should have a subdirectory of the current directory named node_modules. The next steps you need to take:
Create a cordova project:
cordova create MyProject
Add the plugin to the project:
cd MyProject
cordova plugins add ../node_modules/cordova-pdf-generator
The creating of the project was needed for the plugin to be added to it. That step doesn't appear to be listed in the cordova-pdf-generator project on npmjs.com.

Related

Installing and Using Node JS in My Project

Im very very new in NodeJS
I want to ask about installing and using it in my Project..
I've installed nodejs in my Windows, but I have no idea how to make it works in my Cordova/Phonegap Project. I want to install this module in my project node-gcm. it said I just have to execute npm install node-gcm --save but I dont know where should I execute that command so I tried executed it on my project root (/www). After that I tried the example application code to use it but It said that require is not defined. Can anyone tell me how to fix this?
You need to learn nodejs properly to use in your project. I would recommend the below site could be a good starting point for you which covers all the basics.
http://www.tutorialspoint.com/nodejs/
You are getting that error because, when you look at the package.json file of the node-gcm package, you will notice the dependencies mentioned as,
If you are a windows user, you need to get into your node_modules directory by giving cd node_modules command in your command line and then just issue this command npm install which will install all the required packages.
Hope this helps!.

Install node dependencies for Cordova plugin

I'm writing a Cordova plugin, it has a node dependency for one of the hook scripts. Ideally when my plugin is installed:
$ cordova plugin add my-cordova-plugin
I would like it to run npm install if package.json has dependencies listed.
Does Cordova support this feature in some way? Have I missed something?
My current solution is another hook that runs after_plugin_install:
module.exports = function (context) {
var shell = context.requireCordovaModule('shelljs');
shell.cd(context.opts.plugin.dir);
shell.exec('npm install');
};
I you're looking for to add npm modules to your Cordova project, you don't need a plugin, juste use a simple hook triggered before_prepare.
This hook will run all the npm install you need for each cordova prepare (also for cordova run, cordova compile, etc..).
You don't have to make a JS file for a hook, a linux shell script is enough (although it is less portable). I prefer to use juste .sh file when my only need is to do "npm install" or stuff like that.

Issue getting started with Google Web Starter Kit

What you need to know:
I have Node, NPM, Ruby, SASS all installed and at lastest stable realeases. (ruby isn't at it's lastest stable but the lastest stable does not have the sass gem):
https://drive.google.com/folderview?id=0B2JHimBsITS6WHpCTmU4SXBQU28&usp=sharing
I updated npm by using the command line and following the guide on troubleshooting updating npm on windows I USED OPTION 3
I then went back to google's instructions for setting up the starter kit:
$ cd web-starter-kit
$ npm install
$ npm install gulp -g
I scrolled down and followed the steps to "Set Up Your Web Starter Kit Project" keep in mind that i renamed the folder from "web-starter-kit" to "google web" in this case for convenience
So i navigated to the starter kit folder using cmd (with admin rights) and typed
npm install
here are the results:
See link to google drive
I still decided to go ahead and still tried to install gulp using
npm install gulp -g
within the starter kit folder heres the results:
See link to google drive
Who ever helps me rectify this will receive my praise forever...I really want to be using this starter kit to start my projects.
Be sure to reference the install.md for the GWSK git repo.
Looking at your install steps above, you are running npm install before installing Gulp. In the doc I referenced, it's Node.js, Gulp, then run the npm install inside of your project root.
I had errors when using the zipped version of GWSK that I downloaded from GitHub. When I cloned the repo with git, I had a error free clean install and no problems at all.
Cheers - D
EDIT:
OK, here is a step by step on the command line...
First I would have downloaded and installed node.js
Then I would have installed gulp (npm install --global gulp)
I'd then go to my web folder and clone the starter kit into a new project folder: "git clone https://github.com/google/web-starter-kit.git my_new_project"
The I cd into my new project folder and run: "npm install"
You should now be ready to work. While still in your new project folder run "gulp serve". That will start your web server, you can make all your changes in the app folder.
HTH - Don

install cordova failed with node.js command prompt

what is my problem? is it successfully installed or failed? It doesn't seem right for me.
Cordova was installed successfully. You are looking at the dependency tree, so don't worry.
Bear in mind that you have installed the CLI tools. You have to actually create a cordova project with the command before you will see a cordova project.
cordova create <Your project name>

Cordova inAppBrowser plugin issue on windows

so I've been trying to add this plugin with command
cordova plugin add
https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git
which worked on MAC and Linux after
npm update -g cordova
but on windows I'm still getting
cannot read property 'install' of undefined
Moreover - when I'm trying to uninstall ( cordova plugin rm org.apache.cordova.inappbrowser ) then I'm getting
cannot read property 'uninstall' of undefined
Weird thing is that I have two cordova folders - one in
C:\Users\me\AppData\Roaming\npm\node_modules and the second one in
C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules . Path which I added to my environmental variables is C:\Users\mati\AppData\Roaming\npm\node_modules\phonegap\node_modules\.bin
I think that this is the problem reported about a week ago as CB-6008 on the Cordova bug tracker.
It may be a symptom of having an out-of-date cordova installation still. The issue there was solved by removing and reinstalling Cordova to ensure that the latest version was in use.
Delete the content of your platforms and plugins folder. re-install your plugins and the problem should be gone. In my case the following command
phonegap local plugin add org.apache.cordova.inappbrowser
produced -> [error] Cannot read property 'install' of undefined
and the above procedure fixed it.
Have you added a platform to your cordova project (before trying to add a plugin)?
npm update -g cordova
cordova create myproject
cd myproject
cordova platform add android
cordova plugin add _
I think the undefined error means a dependency of the add plugin command is not there.
For me, the solution was to update plugman module:
npm install -g plugman

Resources