Electron中git, npm,webpack使用

开始学习Electron的时候用到git, 记录学习一下, 学习地址是: https://zhuanlan.zhihu.com/p/20225295?columnSlug=FrontendMagazine

1. 用git的时候进入一个目录是 cd D:test  可以进入d盘的文件路劲,跟git没关系

2. 打开 Git bash here

Jason Zeng@DESKTOP-ODB5KQB MINGW32 /e/Jason Zeng/Desktop/Electron
$ git clone https://github.com/bojzi/sound-machine-electron-guide.git                       git克隆远程仓库
Cloning into 'sound-machine-electron-guide'...
remote: Counting objects: 107, done.
remote: Total 107 (delta 0), reused 0 (delta 0), pack-reused 107
Receiving objects: 100% (107/107), 3.37 MiB | 518.00 KiB/s, done.
Resolving deltas: 100% (27/27), done.

Jason Zeng@DESKTOP-ODB5KQB MINGW32 /e/Jason Zeng/Desktop/Electron
$ cd sound-machine-electron-guide                          git 转入目录

Jason Zeng@DESKTOP-ODB5KQB MINGW32 /e/Jason Zeng/Desktop/Electron/sound-machine-electron-guide (master)
$ git tag                                         git 查看tag
00-blank-repository
01-start-project
02-basic-sound-machine
03-closable-sound-machine
04-global-shortcuts-bound
05-settings-window-working
06-shortcuts-configurable
07-ready-for-packaging

Jason Zeng@DESKTOP-ODB5KQB MINGW32 /e/Jason Zeng/Desktop/Electron/sound-machine-electron-guide (master)

$ git checkout 00-blank-repository

Note: checking out '00-blank-repository'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b <new-branch-name>

HEAD is now at aac9eb8... blank repository

 

 

 3. 用node.js command prompt(把Node命令和npm命令都结合的环境)也很蛋疼,要切换一个目录,先要某个盘符下, 如E:后才能进入相应的文件夹, 用相对路劲的方式, 还默认进入了E盘下的第一个文件夹,服了!!!!!!

C:\Windows\System32>E:

E:\WorkSpace>    

E:\WorkSpace>cd ..\SoftwareDistribution

E:\SoftwareDistribution>

E:\SoftwareDistribution>cd ..\Jason Zeng\Desktop\Electron\sound-machine-electron-guide

E:\Jason Zeng\Desktop\Electron\sound-machine-electron-guide>

4. 用node命令框时遇到抛出异常的时候用: ctrl+c 可以退出执行的环境

 

5. npm start的时候遇到两个bug

  1. cannot find module 'app', 把下面的红字改成绿色的即可,错误原因:使用的Electron版本太新,这种API在 Electron v1.0.0 中被移除了。再出现 “Cannot find module ……” 的错误,基本上全是因为require直接引入模块了

    // var app = require('app');
    // var BrowserWindow = require('browser-window');

    const electron = require('electron');
    const app = electron.app;
    const BrowserWindow = electron.BrowserWindow;

    

      2.  loadUrl is not working in electron:   把 loadUrl改成loadURL就可以了

 

界面如下:

 

 

6. nom可以通过package.json来下载依赖模块

  1.package.json不存在时 
  命令:npm init可自动创建package.json文件

  2.package.json存在时 
  直接命令:npm install 或者 npm install –save-dev会自动将package.json中的模块安装到node-modules文件夹下

 

posted @ 2017-02-20 00:03  Jason.Zeng  阅读(1113)  评论(0编辑  收藏  举报