Taro 首次创建小程序 运行报错:(node:7392) UnhandledPromiseRejectionWarning: Error: Cannot find module '@taroj...

如果你taro init myApp 项目选择的是云开发模板或者myApp目录下还有个client目录

目录

请接着往下看,若不是,可能与我遇到的问题不同。错误信息见最下面:

选择云开发模板

此时如果按照官方文档大家会在myApp目录下面使用yarn安装依赖:

安装依赖

其实当前的myApp目录下并不是我们的开发目录,需要cd到 client 目录下,然后再运行 yarn安装依赖

cd 到client目录下

安装依赖:


安装依赖

这样就是安装成功了

运行 yarn dev:weapp时,也要在client目录下哦。



错误信息:

(node:7392) UnhandledPromiseRejectionWarning: Error: Cannot find module '@tarojs/plugin-platform-weapp' from 'C:\Users\Administrator\Desktop\myApp\client'

    at Function.resolveSync [as sync] (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\cli\node_modules\@tarojs\service\node_modules\resolve\lib\sync.js:81:15)

    at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\cli\node_modules\@tarojs\service\dist\utils\index.js:46:31

    at Array.map (<anonymous>)

    at Object.resolvePresetsOrPlugins (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\cli\node_modules\@tarojs\service\dist\utils\index.js:45:30)

    at Kernel.resolvePlugins (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\cli\node_modules\@tarojs\service\dist\Kernel.js:90:36)

    at Kernel.initPresetsAndPlugins (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\cli\node_modules\@tarojs\service\dist\Kernel.js:81:14)

    at Kernel.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\cli\node_modules\@tarojs\service\dist\Kernel.js:40:18)

    at Generator.next (<anonymous>)

    at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\cli\node_modules\@tarojs\service\dist\Kernel.js:8:71

    at new Promise (<anonymous>)

(Use `node --trace-warnings ...` to show where the warning was created)

(node:7392) 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: 2)     

(node:7392) [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.

Done in 4.92s.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容