Running karma after installation results in 'karma' is not recognized as an internal or external command

后端 未结 8 1678
长情又很酷
长情又很酷 2020-12-07 19:48

I\'m trying to run karma as part as an angular-seed project, after installing karma using

npm install -g karma

I get:



        
相关标签:
8条回答
  • 2020-12-07 20:02

    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!

    0 讨论(0)
  • 2020-12-07 20:03

    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.

    0 讨论(0)
  • 2020-12-07 20:08

    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

    0 讨论(0)
  • 2020-12-07 20:08

    '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.

    0 讨论(0)
  • 2020-12-07 20:16

    The command line interface is in a separate package.

    To install this use:

    npm install -g karma-cli

    0 讨论(0)
  • 2020-12-07 20:23

    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...

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