繁体   English   中英

tsc:使用node_modules中的版本

[英]tsc: use version from node_modules

我已经在全球范围内安装了TypeScript,如果我执行tsc -v ,它会打印出Version 2.0.3 我还拥有TypeScript作为我的项目的依赖项,因此编译器也可以作为MyProject/node_modules/.bin/tsc (版本2.0.6

如果在具有node_modules的项目中,是否可以将全局tsc配置为使用本地版本? 基本上,全球tsc只会成为本地tsc的启动器。

我使用grunt-exec来做到这一点,但是模式可以通过多种方式完成。 该cwd进入lib目录,然后在此处执行命令。

这是我的grunt-exec任务,尽管我现在尝试通过Better-npm-run运行它。

“ ts-dev”:{cwd:'node_modules / typescript / lib',cmd:“ node tsc -p ../../../../ -.pretty”}

这是我在Better-npm-run中如何查看任务dev-compile的方法。

      "scripts": {
    "build:dist": "better-npm-run build:dist",
    "build:prod": "better-npm-run build:prod",
    "dev-start": "bnr dev:start",
    "dev-compile": "bnr dev:compile"
  },
  "betterScripts": {
    "dev:start": "node ./serve https://opm-int.nane.netapp.com 9000",
    "dev:compile": "node ./node_modules/typescript/lib/tsc -p ../../../../../ -pretty"
  },

您可以只运行./node_modules/typescript/bin/tsc -v来运行节点版本

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM