簡體   English   中英

使用angular-gettext時,找不到本地Npm模塊“ grunt-angular-gettext”錯誤

[英]Local Npm module “grunt-angular-gettext” not found error when using angular-gettext

我想使用angular-gettext在我的應用程序上實現i18n,因此我遵循了以下http://lostechies.com/gabrielschenker/2014/02/11/angularjspart-12-multi-language-support/的命令:

  npm install -g grunt-cli
  npm install grunt
  npm install grunt-angular-gettext

我的Gruntfile.js:

 module.exports=function(grunt){
grunt.loadNpmTasks('grunt-angular-gettext');
//This task will parse all our source files and extract the texts we want to have translated – the ones that have an associated translate directive – and add them to a so called pot file.
grunt.initConfig({
    nggettext_extract:{ //we define the task name we want to configure or initialize
        pot:{
            files:{
                'po/template.pot':['../templates/*.html'] //we want the task to parse all html files in the current directory or any sub directory of it and output the result of the task into a file called template.pot
            }
        }
    },
    nggettext_compile:{
        all:{
            files:{
            'translations.js':['po/*.po'] //we want this task to load all po files in the subfolder po of the current directory and compile them into a resulting file translations.js located in the current directory.
            }
        }
        }
});

  }

當我使用此命令grunt nggettext_extract提取翻譯時,出現以下錯誤:

  >> Local Npm module "grunt-angular-gettext" not found. Is it installed?
   Warning: Task "nggettext_extract" not found. Use --force to continue.

   Aborted due to warnings.

我不知道為什么? 節點模塊中存在grunt-angular-gettext軟件包,您可以幫助我解決嗎?

嘗試在您的項目文件夾中運行:

npm install grunt-angular-gettext --save-dev

我有一個類似的問題,運行上面的命令對我有用

我不知道這是否對您有幫助,但是我遇到了同樣的錯誤,經過一段時間的研究,我意識到在grunt.initConfig中的nggettext_extract條目不正確,我在錯誤的級別進行了操作(我不小心把它放到了shell中),我知道那不是你的問題,但是在Gruntfile中可能仍然存在。

解決方案是首先確保目錄中有package.json文件。

運行:npm init然后npm install grunt npm install grunt-angular-gettext

這將安裝實際的模塊。 有關此主題的更多信息,請參見: https : //github.com/gruntjs/grunt/issues/232

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM