UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2233) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
在用taro初始化项目的时候遇到以上报错,这是因为权限不足,在初始化命令 taro init 前加上sudo即可,即:
初始化命令,由:
taro init
改为:
sudo taro init
就可以正常创建成功了!
补:之所以要加sudo,是因为没有对此文件或文件夹的读写权限,在开发中,每行命令都要加上sudo有点麻烦,所以建议解决权限问题,从根本上解决。
以MackBook pro为例,开启读写权限步骤如下:
1、找到文件夹,两指同时点击->点击显示简介 (手势可能因为电脑配置不同而有所差异)
2、将当前用户的权限改为 【读与写】
3、 在简介面板的右下角有个锁🔒,点击它,输入用户密码之后就可以打开锁定
4、点击应用到包含的项目,点击确定,就完成授权了,授权结束记得把🔒点击锁上
5、操作到这一步,开发中就不用命令行前加sudo了!
//2021-08-05 补充