当前位置: 首页 > 后端技术 > Node.js

如何在visualstudiocode中直接运行js和ts文件

时间:2023-04-03 22:56:56 Node.js

步骤1.node安装2.查看nodeJs和npm版本node-v和npm-v3.安装Typescriptnpminstall-gtypescript注:查看ts版本tsc-v4.运行自己文件夹下的js文件nodexx.js,先把ts文件转成js文件再执行js文件tscxxx.ts--->转成xxx.js文件再运行js文件,nodexxx.js5.打开环境变量(env),nodeJS,npm配置错误:node:Theitem"node"cannotberecognizedasanameofacmdlet,function,scriptfile,orexecutableprogram.请检查名称的拼写,如果包含路径,请确保其正确并重试。Locationline:1Character:1+node1.js+~~~~+CategoryInfo:ObjectNotFound:(node:String)[],CommandNot解决方法:nodeerrorerror:tsc:UnabletoloadfileC:UsersAdministratorAppDataRoamingnpmtsc.ps1,因为禁止在该系统上运行脚本。有关详细信息,请参阅about_Execution_Policies,网址为https:/go.microsoft.com/fwlink/?LinkID=135170。定位行:1字符:1+tsc2.ts+~~~+CategoryInf解决方法:tsc报错