Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid package.json in Custom cordova plugin

I am trying to develop a custom plugin in cordova that give me location at every specified interval. Problem is that I don't have any package.json file in this plugin directory.

When I am trying to add this plugin into our cordova project i am getting Invalid package.json error.

Please help me I am new in cordova. What i have to do to resolve this error.

I am using this command to add the plugin in project

cordova plugin add ../loccation_plugin/LocationPlugin/
like image 873
Umesh Saraswat Avatar asked Nov 13 '16 08:11

Umesh Saraswat


3 Answers

I had same issue while adding my custom plugin to project. I am using plugman tool to create custom plugin and you may most probably be using plugman tool too.

If that is the case then execute following command to generate valid package.json:

plugman createpackagejson "path of your plugin"

This will ask you some basic question about plugin and will generate package.json file based on it.

like image 54
Rohit Gupta Avatar answered Nov 20 '22 10:11

Rohit Gupta


I meet the same 'pkg is not defined' problem, then I try to use npm init to create package.json file and succeed.

like image 33
user5091911 Avatar answered Nov 20 '22 09:11

user5091911


I had the same issue, but used this npm init instead, press Enter and fill in the data as asked on the cmd

like image 3
Ismael ozil Avatar answered Nov 20 '22 08:11

Ismael ozil