Jim*_*ode 13 node.js npm typescript yarnpkg
错误是什么意思npm ERR! could not determine executable to run意思?
我正在尝试使用打字稿和纱线初始化一个简单的nodejs应用程序。我以前从未真正使用过纱线。
\n我运行了命令:\n yarn init\n成功创建了一个package.json\n npx typescript --init \n给了我上面的错误消息。
版本:\nyarn v1.22.11\nnpx 7.12.0
\n我跑了yarn add typescript,它给了我:
info Direct dependencies\n\xe2\x94\x94\xe2\x94\x80 typescript@4.3.5\ninfo All dependencies\n\xe2\x94\x94\xe2\x94\x80 typescript@4.3.5\nRun Code Online (Sandbox Code Playgroud)\n但当我尝试时typescript -v我得到typescript: command not found
Fel*_*cia 10
扩展JimmyTheCode 的答案,它之所以有效,是因为tsc它是一个仅安装打字稿的虚拟包。
在不安装另一个软件包的情况下解决此问题的正确方法是使用-p|--package上的选项npx。当从包中调用特定的二进制文件时,此标志非常有用。
npx --package typescript tsc --init
# OR
npx -p typescript tsc --init
Run Code Online (Sandbox Code Playgroud)
您可以在npx 的文档中找到更多信息。
| 归档时间: |
|
| 查看次数: |
19867 次 |
| 最近记录: |