龙空技术网

taro安装创建项目问题记录

ITCAN 289

前言:

此时兄弟们对“nodejs安装出错”可能比较关注,同学们都需要了解一些“nodejs安装出错”的相关知识。那么小编同时在网络上搜集了一些关于“nodejs安装出错””的相关文章,希望兄弟们能喜欢,小伙伴们一起来了解一下吧!

1、全局安装“@tarojs/cli”

npm install @tarojs/cli

npm install @tarojs/cli

2、创建项目

taro init my-app

报如下错误:

SyntaxError: Missing catch or finally after try in G:\dev\nvm\v11.4.0\node_modules\@tarojs\cli\templates\default\pkg while compiling ejsIf the above error is not helpful, you may want to try EJS-Lint:, 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重新安装尝试

cnpm install -g @tarojs/cli
4、创建项目
taro init demo

终于成功了!!!

5、运行h5开发又出问题!!!

好无奈!!!

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 监听文件修改中...�   Failed to compile../node_modules/_@tarojs_components@2.2.9@@tarojs/components/src/components/video/style/index.scss 1:0Module 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 ; @charset "UTF-8";|| .taro-video {
6、解决h5运行出错1、在项目根目录下下载安装 @tarojs/plugin-sass
cnpm install @tarojs/plugin-sass
2、在项目目录 config/index plugins下添加@tarojs/plugin-sass3、重新运行命令:npm run dev:h5

成功了!

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 监听文件修改中...✅  Compiled successfully!
7、生成头条小程序时报错
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 ). (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端,微信小程序,头条小程序,都正常,终于熬出头了,哈哈哈哈!!!

标签: #nodejs安装出错