在安装后运行业力会导致“业力”不被认为是内部或外部命令

我试图运行业作为一个 角状种子角状种子项目的一部分,在安装业后使用

npm install -g karma

我得到了:

'karma' is not recognized as an internal or external command, operable program or batch file.

当我试图从 angle-client 脚本运行 test.bat 时,这个文件的内容是:

设置 BASE _ DIR =% ~ dp0

因果报应开始“% BASE _ DIR% . . config karma.con.js”% *

我还试图导航到“ AppData 漫游 npm node _ module 业力本”,并看到了业力文件,当我试图运行它时,我又得到了:

“业力”不被认为是内部或外部命令、可操作程序或批处理文件。

有什么建议吗? 如果没有,请建议如何使用茉莉没有业力。

谢谢。

56026 次浏览

Based upon your directory using \AppData\Roaming, you're on Windows and this error is usually because the path to the npm globals isn't in the Windows PATH or NODE_PATH environment variables.

Use SET to check the values you are using for the paths and if your npm directory isn't listed, that will be the issue.

If you don't want npm to save to this directory, check the npm configuration options and the npm folders docs to see what you can change in this regard...

The command line interface is in a separate package.

To install this use:

npm install -g karma-cli

karma-cli

It is recommended to install karma with its Command-Line-Interface (karma-cli) which will take care of fetching the appropriate karma. You can also install a different local version specific to each project you're working on and karma-cli will pick the appropriate one.

From the karma installation page:

Typing ./node_modules/karma/bin/karma start sucks so you might find it useful to install karma-cli globally:

npm install -g karma-cli

Now, check that karma was installed by typing:

which karma  //echo something like: /usr/local/bin/karma

and check that karma server is working (ctr+c to quit):

karma start

You can also check that karma was installed by going to this directory:

cd /usr/local/lib/node_modules/karma

Good luck!

Official documentation at https://karma-runner.github.io/0.12/intro/installation.html is confusing. It implies that npm install -g karma-cli is to install karma globally but it actually required for to run karma from command line.

'karma' is not recognized as an internal or external command, operable program or batch file.

If the above mentioned solution does not work, than The cause of issue is previous version of nodejs. So uninstall the previous version of nodejs and re-install the latest version. It will resolve your issue. As I faced the same and by doing above changes it worked for me.

Thanks.

I had the same issue and fixed it by correcting my PATH environment variable.

STEP 1: go to the following path and ensure karma.cmd is present at the location given below

[Nodejs folder path]\node_modules\.bin <=> C:\Program Files\nodejs\node_modules\.bin

STEP 2: If present go to STEP 3, If not present run the following command npm install -g karma

STEP 3: Open environment variables and edit PATH

STEP 4: Add the following at the end :

[Nodejs folder path]\node_modules\.bin; <=> "C:\Program Files\nodejs\node_modules\.bin"

Log out your session and it will work for sure.

On windows when you install a npm (non-globally - so without the -g flag), the executable commands are linked in the node_modules\.bin folder.

For example:

powershell> .\node_modules\.bin\karma start

powershell> .\node_modules\.bin\karma run

I had same: 'karma' is not recognized as an internal or external command, operable program or batch file. problem when i tried to install it directly to my project file. When i used npm install -g karma-cli to global install everything worked just fine.