本篇主要解决如下问题:
Error: Invalid Plugin! <plugin name> needs a valid package.json
pkg is not defined
终端切换至自定义插件文件夹的位置:执行如下命令
1. npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help json` for definitive documentation on these fields
and exactly what they do.
Use `npm install --save` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
name: (<plugin name>)
2.输入你的自定义插件名称,不能含大写字母。
3.接下来要填写的信息可依次回车。
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to /Users/..<path> ./pluginName/package.json:
{
"name": "<plugin name>",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Is this ok? (yes)
4.敲入y 即可。
备注,也可以手动创建package.json文件,按照如上(最外层{})格式。未验证。
当前项目环境如下:
xxxxxx: plugman -v
1.5.1
cli packages:(/usr/local/lib/node_modules)
@ionic/cli-utils:1.19.0
ionic(Ionic CLI):3.19.0
global packages:
cordova(Cordova CLI):7.0.1
local packages:
@ionic/app-scripts :3.1.4
Cordova Platforms:android 6.2.3 ios 4.4.0
Ionic Framework:ionic-angular 3.9.2
System:
ios-deploy :1.9.2
Node:v6.11.0
npm:3.10.10
OS:macOS High Sierra
Xcode:Xcode 9.1 Build version 9B55
Environment Variables:
ANDROID_HOME :not set
Misc:
backend :pro
网友评论