问题描述
在学习ts的时候突然报了这个错误,拼写也都很正确,找不到问题的来源:
PS C:\Users\hp\Desktop\source-code\client-side> tslint --init
tslint : 无法将“tslint”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称
的拼写,如果包括路径,请确保路径正确,然后再试一次。
所在位置 行:1 字符: 1
+ tslint --init
+ CategoryInfo : ObjectNotFound: (tslint:String) [], CommandNotFoundExcep
tion
+ FullyQualifiedErrorId : CommandNotFoundException
原因分析:
其实是环境变量的问题。
node.js在安装的时候,环境变量默认给配置到了C:\User[用户名]\AppData\Roaming\npm 里面,但是我的实际位置是安装node的位置的平行文件夹中的“node_node_global”
解决方案:
最后在用户变量中将path改到这个文件夹:
F:\Node\node_global\
PS C:\Users\hp\Desktop\source-code\client-side> tslint --init
Cannot generate tslint.json: file already exists
PS C:\Users\hp\Desktop\source-code\client-side> tslint --project
Invalid option for project: true
最后解决了问题。