Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【20160910】Mac NW.js 环境安装 和 打包 #13

Closed
zhongxia245 opened this issue Sep 9, 2016 · 4 comments
Closed

【20160910】Mac NW.js 环境安装 和 打包 #13

zhongxia245 opened this issue Sep 9, 2016 · 4 comments
Labels

Comments

@zhongxia245
Copy link
Owner

zhongxia245 commented Sep 9, 2016

Mac Nw.js 环境搭建 和 打包

时间:2016-09-10 01:31:22
作者:zhongxia
本文章,以Mac Os 系统为例子。

一、安装NW

安装的方式有两种

1. 下载安装包 官网下载 nw.app 的安装包

把安装包放到 Application 的文件夹里面, 可以双击 nwjs.app ,打开应用。

效果图如下:

设置别名,方便使用

//1. 打开设置别名的文件
vim ~/.bash_profile 

//2.在文件里面添加 上下面这一句
alias nw="/Applications/nwjs.app/Contents/MacOS/nwjs"

//3.使别名生效
source ~/.bash_profile

此时,在命令行输入 nw , 等同双击打开应用

[如果使用了zsh, 可以在 vim ~/.zshrc 里面添加别名 【本人Mac上,别名需要在这里设置才起作用】]

如何使用 nw 打开 项目

nw .    //当前目录下的 package.json  
nw ./xxx/package.json  //其他目录下的package.json 

2. sudo npm install -g nw

由于下载nw,迟迟下载不下来,并且执行 nw 的时候, 一直报错。 后面采用第一种方式。 理论上来讲, npm 上安装好之后, 输入 nw 就可以用了。 【具体需要测试下】

2016-09-10 10:58:36
今天测试了一下是可以用的, 但是推荐使用 npm 包, nwjs 来管理 nw 的版本

npm install -g nwjs  

//列出已安装的 nw 版本
nw ls

//安装指定版本的 nw
nw install 0.17.0    

//使用指定版本的nw
nw use 0.17.0 

打包项目

在Mac 下打包 应用为一个 demo.app 很简单。

//1. 把nwjs.app 复制到你记得住的地方,比如项目的根目录,或者其他
cp -R /Applications/nwjs.app ./test.app 

//2. 把项目的代码打包成  一个 nw 文件 【在项目文件夹里面执行这一句,路径自己根据情况修改】
zip -r ../test.app/Contents/Resources/app.nw  * 

完成, 双击 test.app 即可打开程序

参考文章

  1. 使用nw.js制作桌面应用程序
@zhongxia245 zhongxia245 added the JS label Sep 10, 2016
@zhongxia245
Copy link
Owner Author

注意:

NW 0.13.0+
toolbar默认就为false, 不会出现工具栏,调试也变成需要远程调试。

0.12.3
可以使用工具栏

@Xinboy
Copy link

Xinboy commented Mar 22, 2019

安装后,虽然程序能够运行,但是每次都会报错,一直无法解决
[30418:775:0322/152406.733140:ERROR:component_loader.cc(164)] Failed to parse extension manifest.

@mikedatsko
Copy link

安装后,虽然程序能够运行,但是每次都会报错,一直无法解决
[30418:775:0322/152406.733140:ERROR:component_loader.cc(164)] Failed to parse extension manifest.

I met the same error also.
After a walkaround across the web I found that nw@sdk removes this error notification.
Try to install nw@sdk instead of nw.

@yueyuzhao
Copy link

安装后,虽然程序能够运行,但是每次都会报错,一直无法解决
[30418:775:0322/152406.733140:ERROR:component_loader.cc(164)] Failed to parse extension manifest.

I met the same error also.
After a walkaround across the web I found that nw@sdk removes this error notification.
Try to install nw@sdk instead of nw.

the install command is npm install nw --nwjs_build_type=sdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants