缘由是这样的:

  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 就一切正常了. 这个……