### [学习在Ubuntu 18.04 上搭建微信小程序和公众号应用开发环境](https://www.prosaas.cn/article/16554) **Published:** 2020-08-17T08:43:29 **Author:** 5201314 **Excerpt:** 【相关学习推荐:微信小程序开发教程】在Ubuntu 18.04上 搭建微信小程序和公众号应用的开发环境安装NV… ![](https://img.php.cn/upload/article/000/000/052/5f3a425045d49289.jpg) 【相关学习推荐:微信小程序开发教程】 # 在Ubuntu 18.04上 搭建微信小程序和公众号应用的开发环境 ## 安装NVM 如果在Ubuntu上使用`apt-get`安装了Node.js,需要先手动移除: $ sudo apt-get purge nodejs && sudo apt-get autoremove && sudo apt-get autoclean 安装NVM: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash 或 wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash 安装完毕后,将以下代码加到`~/.bash_profile`, `~/.zshrc`, `~/.profile`, 或者 `~/.bashrc`中: export NVM\_DIR="$(\[ -z "${XDG\_CONFIG\_HOME-}" \] && printf %s "${HOME}/.nvm" || printf %s "${XDG\_CONFIG\_HOME}/nvm")" \[ -s "$NVM\_DIR/nvm.sh" \] && \\. "$NVM\_DIR/nvm.sh" # This loads nvm 测试: ![](https://img.php.cn/upload/article/000/000/052/60f9d14fd83378c7a8740056e2b4d0ea-0.png) **使用淘宝镜像** export NVM\_NODEJS\_ORG\_MIRROR=http://npm.taobao.org/mirrors/node ## NVM 常用指令 **查看本地所有可以用的 Node.js 版本** $ nvm list **查看服务器端可用的 Node.js 版本** $ nvm ls-remote \*_安装 \`8._\` LTS 版本 (长久维护版本) \*\* $ nvm install 8.16.2 **设置默认版本** $ nvm use  8.16.2 $ nvm alias default  8.16.2 **使用淘宝进行加速 NPM** $ npm config set registry=https://registry.npm.taobao.org **将 NPM 更新到最新** $ npm install -g npm **检测版本** $ npm -v ## 安装Yarn **第一种方法:安装`稳定版1.19.1`** 配置仓库: url -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list 安装: sudo apt-get update && sudo apt-get install --no-install-recommends yarn 第二种方法: 通过npm安装 npm install --global yarn 然后在终端中设置PATH环境变量(即把以下代码添加到 `~/.bash_profile`, `~/.zshrc`, `~/.profile`, 或者 `~/.bashrc`) export PATH="$PATH:\`yarn global bin\`" 最后运行命令测试Yarn是否安装成功: yarn --version ![](https://img.php.cn/upload/article/000/000/052/ef28cde4a095cb039bddb7bc2e48652c-1.png) ## 安装 Linux微信web开发者工具 **下载项目和初始化** git clone https://github.com/cytle/wechat\_web\_devtools.git cd wechat\_web\_devtools # 自动下载最新 \`nw.js\` , 同时部署目录 \`~/.config/wechat\_web\_devtools/\` ./bin/wxdt install **安装Wine** sudo apt-get install wine-binfmt sudo update-binfmts --import /usr/share/binfmts/wine **启动ide,开发和调试网页** ./bin/wxdt # 启动 ![](https://img.php.cn/upload/article/000/000/052/ef28cde4a095cb039bddb7bc2e48652c-2.png) ## 小程序基础环境搭建 **安装wepy-ci** WePY 是一个小程序组件化开发框架,开发风格接近 Vue.js,更贴近于 MVVM 架构模式,相比小程序原生开发要更加的方便快捷。 yarn global add wepy-cli **初始化项目** mkdir helloworld cd helloworld  helloworld  wepy init standard ./ ![](https://img.php.cn/upload/article/000/000/052/ef28cde4a095cb039bddb7bc2e48652c-3.png) 对项目进行编译,并持续监听代码变化\*\* wepy build --watch ![](https://img.php.cn/upload/article/000/000/052/fc43c650fc60e2ac814970ca711b2358-4.png) > 相关学习推荐:微信公众号开发教程 以上就是学习在Ubuntu 18.04 上搭建微信小程序和公众号应用开发环境的详细内容,更多请关注知企PROSAAS其它相关文章! **Categories:** 后端开发 ---