隔一段时间就要再次开始一次, 充分证明了这货的开发方式反人类

更新

过了一段时间再次运行我的electron项目, 发现报错, 提示我更新.

# npm很容易更新
 npm i npm 
 npm update
 
# 然后我们还需要更新node
 brew install nvm
 nvm install node                                  
# 然后提示我:  command not found: nvm
# 此时 下面命令的结果是含有nvm的
brew list 

# 安装的最后阶段有一堆话:
Caveats
Please note that upstream has asked us to make explicit managing
nvm via Homebrew is unsupported by them and you should check any
problems against the standard nvm install method prior to reporting.

You should create NVM's working directory if it doesn't exist:

  mkdir ~/.nvm

Add the following to ~/.zshrc or your desired shell
configuration file:

  export NVM_DIR="$HOME/.nvm"
  . "/usr/local/opt/nvm/nvm.sh"

You can set $NVM_DIR to any location, but leaving it unchanged from
/usr/local/opt/nvm will destroy any nvm-installed Node installations
upon upgrade/reinstall.

Type `nvm help` for further information.

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
# 照着这个做就好了. 然后升级node
nvm install nodell
# 然后提示electron . 找不到
electron .
zsh: command not found: electron
# 按照官网来
npm install && npm start
# 成功了

参考的这个: https://www.hostingadvice.com/how-to/update-node-js-latest-version/#winmac

之前一次的从头开始

缘由是这样的:

  1. 为了关联app和文件类型, 我尝试了electron-forge,
    • 在这个过程中, cnpm install -g electron-prebuilt-compile
  2. 然后发现electron-forge不满足要求. 改为尝试electron-builder
    • electron-builder 要求用yarn, 因此: brew install yarn
  3. 然后, electron . 执行我的工作目录, 失败, 报了一堆错.
  4. 尝试在工作目录yarn解决, 但是, 巨慢…..
  5. 然后尝试: cnpm uninstall -g electron-prebuilt-compile
  6. 只更新不卸载, 改为: npm uninstall -g electron-prebuilt-compile
  7. 牛死了, 这个卸载了所有的全局内容. 再次运行electron .的时候, 系统提示没有这个命令.

从头再来

  1. 不论是yarn还是npm都不成, 那么删除node_modules目录,
  2. 这次试试yarn
  3. yarn依旧报错, 只能试试cnpm了.
  4. cnpm也一堆警告, 修改一下,
    1. 删除了一个不靠谱的依赖.
    2. npm electron iconv-lite的依赖都改为: latest.
  5. npm start 成功了.
  6. 再试试yarn

yarn有警告

 yarn
yarn install v1.5.1
warning package.json: License should be a valid SPDX license expression
info No lockfile found.
warning my-hope@1.0.0: License should be a valid SPDX license expression
[1/4] 🔍  Resolving packages...
warning npm > npm-profile > make-fetch-happen > socks-proxy-agent > socks@1.1.10: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
error An unexpected error occurred: "ENOENT: no such file or directory, copyfile '/Users/machangkun/Library/Caches/Yarn/v1/npm-find-up-1.1.2-6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f/license' -> '/Users/machangkun/Documents/_X/_知网justdoit/doing master/try/node_modules/meow/node_modules/find-up/license'".
info If you think this is a bug, please open a bug report with the information provided in "/Users/machangkun/Documents/_X/_知网justdoit/doing master/try/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

再次yarn 就一切正常了. 这个……