tsc is not recognized as an internal or external command

后端 未结 3 1264
生来不讨喜
生来不讨喜 2021-01-21 08:40

I am using node version 6.9.2 with npm version 5.4.2 on Windows7. I have installed typescript with the command npm install typescript -g.

However, when I r

相关标签:
3条回答
  • 2021-01-21 08:56

    Install node version 6.11 and things work without any changes.

    0 讨论(0)
  • 2021-01-21 09:12

    The problem is likely that tsc is not in the system path.

    First, check if tsc is installed correctly. Open cmd.exe and type the following.

    %AppData%\npm\node_modules\typescript\bin\tsc --version
    

    If there is a version log, then tsc is installed successfully.

    The next thing is to add it in PATH. Write in cmd.exe

    setx path "%path%;%AppData%\npm\node_modules\.bin\"
    

    This should solve the issue.

    However, if the first command did not log the version,

    Check the install location using

    npm list -g
    

    If typescript appears in the output, copy the location to the PATH as

    setx path "%path%;<--the tsc.exe path-->"
    

    Hope this helps.

    0 讨论(0)
  • 2021-01-21 09:12

    Since you installed it globally and you had no error, I can assume that the installation succeeded.

    To be sure, you can run this command npm config get prefix. It will output the path of the folder containing all packages installed globally by npm. I you go to the folder specified by the path, there is a nodes_modules subfolder. It should contain a typescript folder if the installation succeeded. Then copy the path of the bin of the typescript folder in your environment variable. You should label the path tsc.

    Then you can use tsc in command line.

    0 讨论(0)
提交回复
热议问题