简体   繁体   English

NPM 不会自动为我设置 cmdlet?

[英]NPM won't automatically set up cmdlet's for me?

this is the first this ever happened to me.这是第一次发生在我身上。

I am trying to install a documentation generator ( docma ) and for some reason I follow everything they say in the docs and can't execute 'docma' or 'docma serve', it says it's not recognized as a cmdlet, tried it on my Linux machine and it also isn't recognized as a command, so there's no way for me to serve my documentation and the developer stopped supporting that years ago.我正在尝试安装文档生成器 ( docma ),出于某种原因,我遵循了他们在文档中所说的所有内容,无法执行“docma”或“docma serve”,它说它不被识别为 cmdlet,在我的Linux 机器,它也没有被识别为命令,所以我无法提供我的文档,开发人员在几年前就停止了支持。

Thanks in advance提前致谢

EDIT: I should add that I don't get a node_modules folder编辑:我应该补充一点,我没有得到 node_modules 文件夹

If you don't have a package.json file for your project, create one:如果您的项目没有package.json文件,请创建一个:

npm init

(If you don't care about what the contents of the package.json file are, then you can accept all the defaults with npm init -y rather than answer the questions the command will ask you.) (如果您不关心package.json文件的内容是什么,那么您可以使用npm init -y接受所有默认值,而不是回答问题。)

The documentation says to install docma in a project like this:文档说要在这样的项目中安装docma

npm i docma -D

Do that.去做。 That will create a node_modules directory if you don't already have one.如果您还没有node_modules目录,这将创建一个目录。

From there, all the commands in the docma documentation can be executed from the command line if you precede them with npx .从那里,如果您在它们前面加上npx ,则可以从命令行执行docma文档中的所有命令。 So where it says docma , you can use npx docma .所以在它说docma的地方,你可以使用npx docma And where it says docma serve , you can use npx docma serve .在它说docma serve的地方,你可以使用npx docma serve (You will need to be in your project directory for this to work!) (你需要在你的项目目录中才能工作!)

Another solution would be to install docma globally ( npm i docma -g ) but that has its own risks and complications (such as requiring elevated privileges in some situations).另一种解决方案是全局安装docmanpm i docma -g ),但这有其自身的风险和复杂性(例如在某些情况下需要提升权限)。 What I've described above is (IMO) safer and better.我上面描述的是(IMO)更安全、更好。

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

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