Ошибка локального модуля Npm grunt-angular-gettext не найдена при использовании 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 существует в модулях узла, можете ли вы помочь мне справиться с этим?


person hanane    schedule 07.03.2014    source источник


Ответы (3)


Попробуйте запустить в папке вашего проекта:

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

У меня была аналогичная проблема, и выполнение вышеуказанной команды помогло мне.

person AndreiC    schedule 25.04.2014

Я не знаю, поможет это вам или нет, но у меня была такая же ошибка, и через некоторое время, посмотрев на нее, я понял, что моя запись nggettext_extract в grunt.initConfig была неправильной, у меня она была на неправильном уровне ( Я случайно поместил его в оболочку), я вижу, что это не ваша проблема, но это все еще может быть что-то в Gruntfile.

person Carlos    schedule 26.03.2014

Решение состоит в том, чтобы сначала убедиться, что у вас есть файл package.json в каталоге.

запустить: npm init затем npm установить grunt npm установить grunt-angular-gettext

Это установит фактический модуль. Дополнительную информацию по этой теме можно найти: https://github.com/gruntjs/grunt/issues/232

person afabijan    schedule 14.01.2016