1:错误如下:
VM1364:1 npm
(anonymous) @ VM1364:1
VM1365:1 ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! miniprogram-ts-quickstart@1.0.0 tsc: `node ./node_modules/typescript/lib/tsc.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the miniprogram-ts-quickstart@1.0.0 tsc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
(anonymous) @ VM1365:1
VM1366:1
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2021-05-30T02_52_09_395Z-debug.log
此错误是微信开发最常见的错误,报错的原因是写ts代码的一些常见错误,令人费解的是变量没使用也会编译不通过,这是最让我无语的地方。
2:解决思路
可以通过ts错误忽略具体的错误,如
// @ts-ignore
放在错误代码的前一行,如果还是编译不通过,最简单粗暴的方法就是在每一个ts文件的头一行添加
// @ts-nocheck
此方法是忽略该ts文件注释下面的全部代码的错误检查
一个小提示:
ts错误被一闪而过,刚开发的小白必定会很抓狂,对此,我也是一堆的莫名其妙,可以在日记里选上Preserve log选项: