【发布时间】:2014-05-12 07:53:54
【问题描述】:
我已经使用我的 NW 应用程序工作了几个星期,没有出现任何问题。我开始将其他同事带入我的仓库进行测试,我决定编写一个安装脚本,而不是强迫他们手动安装依赖项。今天,运行安装脚本测试后,我尝试运行我的应用程序并得到以下错误:
Invalid package.json
Field 'main' is required.
我没有对我的应用程序或我的 package.json 文件进行任何更改。我不知道是什么原因导致了这个问题,但在 NW 的 GitHub 存储库上似乎确实存在一个未解决的问题,其中谈到了这一点:
https://github.com/rogerwang/node-webkit/issues/1503
我想知道是否有其他人遇到过这种情况,您可能采取了哪些措施来解决此问题?
以下是关于我的应用的一些相关信息。
node-webkit: v0.8.5
node.js: v0.10.22
Chromium: 30.0.1599.66
bower: 1.3.1
yeoman: 1.1.2
我尝试获取 nodewebkit 本身的版本,但命令 nodewebkit 没有提供版本标志。
安装 shell 脚本
npm install bower -g
npm install yeoman -g
npm install generator-node-webkit -g
npm install nodewebkit -g
npm install grunt-cli -g
bower install
npm install
我的目录树(从根目录):
├── Gruntfile.js
├── app
│ ├── css
│ │ ├── main.css
│ ├── index.html
│ ├── js
│ │ ├── application.js
│ └── package.json
├── bower.json
├── package.json
我最里面的 package.json 文件,在我的主应用程序目录中:
{
"name": "directory",
"main": "index.html",
"version": "0.0.1",
"single-instance": true,
"window": {
//"toolbar": false,
"title": "Directory",
"width": 850,
"height": 600,
"min_width": 850,
"min_height": 600
},
"chromium-args": "--child-clean-exit"
}
这是最外层的 package.json:
{
"name": "directory",
"version": "0.0.0",
"main": "app/index.html",
"description": "",
"keywords": [],
"dependencies": {
"xls-to-json": "~0.2.0"
},
"devDependencies": {
"matchdep": "~0.1.2",
"grunt": "~0.4.1",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-sass": "~0.4.1",
"grunt-contrib-concat": "~0.1.3",
"grunt-contrib-jshint": "~0.4.3",
"grunt-contrib-clean": "~0.4.1",
"grunt-contrib-rename": "0.0.3",
"grunt-contrib-compress": "~0.5.3",
"xls-to-json": "~0.2.0"
},
"engines": {
"node": ">=0.8.0"
}
}
【问题讨论】:
标签: node.js node-webkit