【发布时间】:2023-03-19 23:40:02
【问题描述】:
我目前正在尝试第一次在我的机器上安装 typescript。安装节点后,我运行以下命令:
sudo npm -g install typescript
这会产生似乎是积极的安装消息
/Users/mac/.npm-global/bin/tsc -> /Users/mac/.npm-global/lib/node_modules/typescript/bin/tsc /Users/mac/.npm-global/bin/tsserver -> /Users/mac/.npm-global/lib/node_modules/typescript/bin/tsserver + typescript@3.4.4 在 0.924 秒内更新了 1 个包
在此之后,我检查安装是否成功但正在运行 tsc --version 并收到以下错误:
tsc: command not found
来自我尝试过的另一个线程:
重启终端
重新启动机器
重新安装 nodejs + 然后运行sudo npm install typescript -g
我还尝试使用以下行更新我的 bash 配置文件:
export PATH="$PATH:"/Users/mac/.npm-global/lib/node_modules/typescript/bin/tsc"";
我不确定 typescript 是否位于我列出的位置。有没有办法确认?
任何帮助将不胜感激。
【问题讨论】:
-
I have also tried updating my bash profile with the following line你应该将路径添加到 bin 目录,而不是可执行文件本身。 -
非常感谢您非常及时和乐于助人的回复。事实上,这就是问题所在。将我的 bash 配置文件更改为 /Users/mac/.npm-global/lib/node_modules/typescript/bin 立即解决了这个问题。
-
@tkausl:您可以将其发布为答案——或者问题应该关闭或删除。
标签: typescript npm command-line