为何不能直接直接运行vue-cli-service?

我可以使用 npm run serve 进而运行

vue-cli-service serve

image.png

能够正常运行起来:
image.png

可以为何我不能直接在命令行运行vue-cli-service serve
image.png

$ vue-cli-service serve
'vue-cli-service' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
阅读 2.8k
1 个回答

请参看官方文档的说明: https://docs.npmjs.com/cli/v8...

In addition to the shell's pre-existing PATH, npm run adds node_modules/.bin to the PATH provided to scripts. Any binaries provided by locally-installed dependencies can be used without the node_modules/.bin prefix.

npm install安装的包有可执行程序的会安装在node_modules/.bin/目录下,而npm run会在执行的时候自动追加这个路径到PATH

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题