1、全局安装“@tarojs/cli”
1 |
npm install @tarojs/cli |
2、创建项目
1 |
taro init my-app |
报如下错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
SyntaxError: Missing catch or finally after try in G:\dev\nvm\v11.4.0\node_modules\@tarojs\cli\templates\default\pkg while compiling ejs If the above error is not helpful, you may want to try EJS-Lint: https://github.com/RyanZim/EJS-Lint Or, if you meant to create an async function, pass `async: true` as an option. at new Function (<anonymous>) at Template.compile (G:\dev\nvm\v11.4.0\node_modules\@tarojs\cli\node_modules\ejs\lib\ejs.js:652:12) at Object.compile (G:\dev\nvm\v11.4.0\node_modules\@tarojs\cli\node_modules\ejs\lib\ejs.js:392:16) at handleCache (G:\dev\nvm\v11.4.0\node_modules\@tarojs\cli\node_modules\ejs\lib\ejs.js:215:18) at Object.exports.render (G:\dev\nvm\v11.4.0\node_modules\@tarojs\cli\node_modules\ejs\lib\ejs.js:419:10) at render (G:\dev\nvm\v11.4.0\node_modules\@tarojs\cli\node_modules\mem-fs-editor\lib\actions\copy-tpl.js:14:18) at process (G:\dev\nvm\v11.4.0\node_modules\@tarojs\cli\node_modules\mem-fs-editor\lib\actions\copy-tpl.js:31:14) at applyProcessingFunc (G:\dev\nvm\v11.4.0\node_modules\@tarojs\cli\node_modules\mem-fs-editor\lib\actions\copy.js:14:16) at EditionInterface.exports._copySingle (G:\dev\nvm\v11.4.0\node_modules\@tarojs\cli\node_modules\mem-fs-editor\lib\actions\copy.js:64:16) at files.forEach.file (G:\dev\nvm\v11.4.0\node_modules\@tarojs\cli\node_modules\mem-fs-editor\lib\actions\copy.js:51:10) |
然后就是各种问题查找,网上找啊找,没找到答案。。。
3、卸载@tarojs/cli用cnpm重新安装尝试
1 |
cnpm install -g @tarojs/cli |
4、创建项目
1 |
taro init demo |
终于成功了!!!
5、运行h5开发又出问题!!!
好无奈!!!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
PS G:\react\ttt\demo> npm run dev:h5 > demo@1.0.0 dev:h5 G:\react\ttt\demo > npm run build:h5 -- --watch > demo@1.0.0 build:h5 G:\react\ttt\demo > taro build --type h5 "--watch" � Taro v2.2.9 创建 发现文件 src\app.styl 创建 发现文件 src\app.tsx 创建 发现文件 src\index.html 创建 发现文件 src\pages\index\index.styl 创建 发现文件 src\pages\index\index.tsx ℹ️ Listening at http://0.0.0.0:10086/ 监听文件修改中... � Failed to compile. ./node_modules/_@tarojs_components@2.2.9@@tarojs/components/src/components/video/style/index.scss 1:0 Module parse failed: Unexpected character '@' (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders > @charset "UTF-8"; | | .taro-video { |
6、解决h5运行出错
- 1、在项目根目录下下载安装 @tarojs/plugin-sass
1 |
cnpm install @tarojs/plugin-sass |
- 2、在项目目录 config/index plugins下添加@tarojs/plugin-sass
- 3、重新运行命令:npm run dev:h5
成功了!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
PS G:\react\ttt\demo> npm run dev:h5 > demo@1.0.0 dev:h5 G:\react\ttt\demo > npm run build:h5 -- --watch > demo@1.0.0 build:h5 G:\react\ttt\demo > taro build --type h5 "--watch" � Taro v2.2.9 创建 发现文件 src\app.styl 创建 发现文件 src\app.tsx 创建 发现文件 src\index.html 创建 发现文件 src\pages\index\index.styl 创建 发现文件 src\pages\index\index.tsx ℹ️ Listening at http://0.0.0.0:10086/ 监听文件修改中... ✅ Compiled successfully! |
7、生成头条小程序时报错
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
PS G:\react\ttt\demo> npm run dev:tt > demo@1.0.0 dev:tt G:\react\ttt\demo > npm run build:tt -- --watch > demo@1.0.0 build:tt G:\react\ttt\demo > taro build --type tt "--watch" � Taro v2.2.9 (node:17652) UnhandledPromiseRejectionWarning: Error: EPERM: operation not permitted, mkdir 'G:\react\ttt\demo\dist' at Object.mkdirSync (fs.js:914:3) at Object.mkdirsSync (G:\dev\nvm\v12.18.0\node_modules\@tarojs\cli\node_modules\_fs-extra@8.1.0@fs-extra\lib\mkdirs\mkdirs-sync.js:31:9) at Object.<anonymous> (G:\dev\nvm\v12.18.0\node_modules\@tarojs\cli\dist\presets\commands\build.js:60:20) at Generator.next (<anonymous>) at fulfilled (G:\dev\nvm\v12.18.0\node_modules\@tarojs\cli\dist\presets\commands\build.js:4:58) at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:17652) 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:17652) [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. |
关闭模拟器后尝试:npm run dev:tt,正常了
试了h5端,微信小程序,头条小程序,都正常,甚为欣慰!!!