Javascript Grunt nunjucks-2-html

Javascript Grunt nunjucks-2-html,javascript,gruntjs,nunjucks,Javascript,Gruntjs,Nunjucks,我正试图通过grunt nunjucks-2-html编译我的模板: 这是我的简化grunt文件: module.exports = function(grunt) { grunt.initConfig({ nunjucks: { options: { data: {}, paths: '/templates/' }, render: {

我正试图通过grunt nunjucks-2-html编译我的模板:

这是我的简化grunt文件:

module.exports = function(grunt) {

grunt.initConfig({
      nunjucks: {
          options: {
              data: {},
              paths: '/templates/'
          },
          render: {
              files: [
                  {
                      expand: true,
                      src: '*.html',
                      cwd: '/templates',
                      dest: 'build',
                      ext: '.html'

                  }
              ]
          }
      }
  });

  grunt.loadNpmTasks('grunt-nunjucks-2-html');
};
我的文件夹结构如下所示:

```
project
│   Gruntfile.js
│
└───templates
│      index.html
│      foo.html
│  
└───build

```
运行grunt nunjucks时,出现以下错误:

正在运行“nunjucks:render”(nunjucks)任务,未指定任何文件。“ 很明显,nunjucks找不到我的模板。 我不知道在哪里配置模板路径,对我来说我的gruntfile似乎有效。如果你知道的话,我很高兴


谢谢大家!

变量引用GrunFile所在的目录


您可以尝试使用
路径:\uuu dirname+'/templates/'
或只使用
路径:'templates'
,如中所述。

\uu dirname
变量引用Grunfile所在的目录

您可以尝试使用路径:uu dirname+'/templates/',或者只使用路径:'templates',如中所述