tarojs项目启动篇

TaroJS 是一个开放式跨端开发解决方案,使用 React 语法规范来开发多端应用(包括小程序、H5、React Native 等)。它可以帮助开发者高效地构建出在不同端上运行一致的应用。以下是启动 TaroJS 项目(本来就有的旧项目)的步骤

1. 安装项目依赖

在项目目录中,运行以下命令来安装项目依赖:npm i (是我们大家都无比熟悉的)

然后我们发现了奇奇怪怪的问题

1.1淘宝镜像过期问题

request to https://registry.npm.taobao.org/@babel%2Fruntime failed, reason: certificate has expired

这个问题跑老项目的话还是很常见的正常的话我们 执行一下下面的代码就解决了这个问题了

javascript 复制代码
npm config set registry https://registry.npmmirror.com

没有解决的BB我们一起来看下一步

这时候你需要看一下你的npm 配置 瞅瞅你那registry 是不是成功设置了 再试一遍

javascript 复制代码
npm config list

如果做了上一步还是没有好 BB那你可能和我一样的惨和粗心 没有注意到项目里面有个npm的配置文件 把这玩意改了或者删了就完美的解决了这个问题了

1.2装包眼看着就到最后了 报错

这种事情无疑是让人非常之厌恶的

cb never called

它报了一个这样的错误 这个错误的原因是回调函数没有正常的执行 出现这个东西的话 你可以考虑一下 切个网络 重来一遍 因为这个一般发生在你的网络不稳定的情况下

好了我们切换了网络 然后它又癫了

WARN @babel/eslint-parser@7.24.8 requires a peer of eslint@^7.5.0 || ^8.0.0 || ^9.0.0 but none is installed. You must install peer dependencies yourself. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! electron@11.5.0 postinstall: `node install.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the electron@11.5.0 postinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\gandongzhan\AppData\Roaming\npm-cache\_logs\2024-07-24T03_31_14_530Z-debug.log

报错内容如上

1.2.1. 解决依赖版本不匹配问题

@babel/eslint-parser 需要一个与 eslint 相关的对等依赖(peer dependency),但您的系统中没有安装满足条件的 eslint 版本。您可以尝试安装一个合适的 eslint 版本。根据您的项目需求,您可以选择安装 eslint 的 7.x、8.x 或 9.x 版本。

例如,使用 npm 安装 eslint 8.x 版本:

javascript 复制代码
npm install eslint@^8.0.0 --save-dev
1.2.2 electron 包下不下来

这个东西 嗯 就是说 这个东西要配另外的镜像

可以一个一个设置

javascript 复制代码
npm config set electron_mirror https://registry.npmmirror.com/-/binary/electron/  
npm config set electron_builder_binaries_mirror https://registry.npmmirror.com/-/binary/electron-builder-binaries/

也可以去改C盘用户下的.npmrc文件

javascript 复制代码
registry=https://registry.npmmirror.com/
disturl=https://registry.npmmirror.com/-/binary/node/
sass_binary_site=https://registry.npmmirror.com/node-sass
phantomjs_cdnurl=https://registry.npmmirror.com/phantomjs
chromedriver_cdnurl=https://registry.npmmirror.com/-/binary/chromedriver/
operadriver_cdnurl=https://registry.npmmirror.com/-/binary/operadriver/
electron_mirror=https://registry.npmmirror.com/-/binary/electron/
electron_builder_binaries_mirror=https://registry.npmmirror.com/-/binary/electron-builder-binaries/
always-auth=false
 

2. 启动打包项目

微信小程序为例子 (依赖里面需要装的有对应的插件包哈)

javascript 复制代码
npm run dev:weapp

打包的话 看看package.json文件里的配置项 能跑打包一般不会出问题的

相关推荐
卡兰芙的微笑19 分钟前
get_property --Cmakelist之中
前端·数据库·编辑器
覆水难收呀21 分钟前
三、(JS)JS中常见的表单事件
开发语言·前端·javascript
猿来如此呀29 分钟前
运行npm install 时,卡在sill idealTree buildDeps没有反应
前端·npm·node.js
hw_happy34 分钟前
解决 npm ERR! node-sass 和 gyp ERR! node-gyp 报错问题
前端·npm·sass
FHKHH39 分钟前
计算机网络第二章:作业 1: Web 服务器
服务器·前端·计算机网络
视觉小鸟1 小时前
【JVM安装MinIO】
前端·jvm·chrome
二川bro2 小时前
【已解决】Uncaught RangeError: Maximum depth reached
前端
qq22951165023 小时前
python毕业设计基于django+vue医院社区医疗挂号预约综合管理系统7918h-pycharm-flask
前端·vue.js·express
WebGIS皮卡茂3 小时前
【数据可视化】Arcgis api4.x 热力图、时间动态热力图、timeSlider时间滑块控件应用 (超详细、附免费教学数据、收藏!)
javascript·vue.js·arcgis·信息可视化
八了个戒3 小时前
Koa (下一代web框架) 【Node.js进阶】
前端·node.js