标签: gruntjs

带有grunt的Nodeunit找不到模块'tap'

因此,在本教程的帮助下,我决定在我的node.js应用程序中添加一些单元测试.我的gruntfile似乎没问题,当我输入grunt nodeunit我的唯一测试运行就好了,但在那之后,它崩溃了错误Fatal error: Cannot find module 'tap':

$> grunt nodeunit
Running "nodeunit:all" (nodeunit) task
Testing db.test.js
.OK
Fatal error: Cannot find module 'tap'
Run Code Online (Sandbox Code Playgroud)

我对这个模块一无所知,但是在搞砸之后,似乎这是nodeunit需要的东西.事实上,它$MY_NODE_APP/node_modules/nodeunit/node_modules/tap存在:存在,当我启动节点$MY_NODE_APP/node_modules/nodeunit并输入require('tap')交互式控制台时,我得到一些带有很多东西的对象,这给我的印象是它应该正常工作.

所以,显而易见的问题是:为什么我会收到此错误,我该如何解决?

Gruntfile:

module.exports = function(grunt) {

    grunt.initConfig({
        nodeunit: {
            all: ['./**/*.test.js']
        }
    });

    grunt.loadNpmTasks('grunt-contrib-nodeunit');
};
Run Code Online (Sandbox Code Playgroud)

更新:安装tap到我的项目,但它也没有帮助.

node.js npm requirejs nodeunit gruntjs

1
推荐指数
1
解决办法
2207
查看次数

错误"致命错误:无法找到本地咕噜声." 在构建atom.io时

我试图构建atom.io并完成构建脚本没有任何错误.但是当我尝试运行"./grunt install"时,我总是会收到以下错误:

grunt-cli: The grunt command line interface. (v0.1.13)

Fatal error: Unable to find local grunt.

If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:

http://gruntjs.com/getting-started
Run Code Online (Sandbox Code Playgroud)

所以我按照" http://gruntjs.com/getting-started "的建议尝试了以下命令:

sudo npm install grunt --save-dev
Run Code Online (Sandbox Code Playgroud)

这提供了以下输出:

andreas@debian ~/atom.io $ sudo npm install grunt --save-dev
npm http GET https://registry.npmjs.org/grunt
npm http 304 https://registry.npmjs.org/grunt
npm http GET https://registry.npmjs.org/async
npm …
Run Code Online (Sandbox Code Playgroud)

linux-mint gruntjs atom-editor

1
推荐指数
1
解决办法
7323
查看次数

`致命错误:无法找到当地的咕噜声.:为什么要求当地的咕噜声,如果我有全球性的?

我是Node.js中的菜鸟,并试图用来grunt-contrib-concat从多个源文件构建我的javascript库.

我创建了一个虚拟环境,激活它,全球的装机量gruntgrunt-cli书面Gruntfile.jspackage.json文件为我的项目.总结一下:

$ nodenv NODEENV
$ source NODENV/bin/activate
(NODEENV)$ npm install -g grunt-cli
...
(NODEENV)$ npm install -g grunt
...
(NODEENV)$ cd myproject
(NODEENV)$ ls myproject
Gruntfile.js package.json src test README.md
(NODEENV)$ grunt test
grunt-cli: The grunt command line interface. (v0.1.13)

Fatal error: Unable to find local grunt.

If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information …
Run Code Online (Sandbox Code Playgroud)

javascript node.js gruntjs

1
推荐指数
1
解决办法
8274
查看次数

grunt-contrib-cssmin缺少_stream_transform模块

尝试从GruntJs运行css缩小时出现以下错误,我不知道为什么.

Loading "cssmin.js" tasks...ERROR 
>> Error: Cannot find module '_stream_transform
Run Code Online (Sandbox Code Playgroud)

此错误消息的来源是什么?我搜索了cssmin.js文件,找不到该模块的单个引用.

gruntjs grunt-contrib-cssmin

1
推荐指数
1
解决办法
2109
查看次数

Karma public api缺少configFile选项

gulp-karma建议像这样的外部配置文件:

module.exports = {
    basePath: '',
    singleRun: true
};
Run Code Online (Sandbox Code Playgroud)

我想要一个像这样的外部配置文件(grunt-karma样式):

module.exports = function(config) {
    config.set({
         basePath: '',
         singleRun: true
    });
};
Run Code Online (Sandbox Code Playgroud)

如何使用proper config filewith karma API.

细节:

我使用一饮而尽-卡玛,并提到 ,我要实现它在我自己的.

Karma API非常简单:

var server = require('karma').server;
server.start(config, done);
Run Code Online (Sandbox Code Playgroud)

config变量很模糊.它是一个配置的普通对象:

var config = {
    basePath: '',
    singleRun: true
    // ...
}
Run Code Online (Sandbox Code Playgroud)

我们来看看grunt-karma:

示例grunt-karma配置:

karma: {
  unit: {
      configFile: 'karma.conf.js'
  }
}
Run Code Online (Sandbox Code Playgroud)

grunt-karma配置可以采取一个configFile选项,这在任何地方都没有记录.

我可以看到,我可以configFilekarma源代码传递一个选项:

var config = cfg.parseConfig(cliOptions.configFile, …

javascript node.js gruntjs karma-runner gulp

1
推荐指数
1
解决办法
1368
查看次数

如何运行grunt docular-server?

如果我执行命令 grunt docular-server

我收到错误消息:

ERROR: Could not start node server [TypeError: Object #<Object> has no method 'server']

那么docular-server没有运行.

我安装了grunt来编写我的代码文档,如下所示:

 `npm install -g grunt-cli`
 `npm install grunt grunt-docular`
Run Code Online (Sandbox Code Playgroud)

Gruntfile.js看起来像这样:

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({

pkg: grunt.file.readJSON('package.json'),

docular: {
groups: [],
showDocularDocs: true,
showAngularDocs: true
}

});

// Load the plugin that provides the "docular" tasks.
grunt.loadNpmTasks('grunt-docular');

// Default task(s).
grunt.registerTask('default', ['docular']);

};
Run Code Online (Sandbox Code Playgroud)

这个例子来自官方网站:

http://grunt-docular.com/documentation/docular/docularinstall/installdocular

documentation documentation-generation node.js gruntjs

1
推荐指数
1
解决办法
1302
查看次数

grunt sass为输出文件添加注释

我正在使用grunt sass在Wordpress主题中输出我的CSS.

我通常会将我的CSS输出到thestyles.css并在style.css中使用@import(thestyles.css)

我正在使用respond.js所以我不能在style.css文件中使用@import.

我想直接输出我的CSS到style.css但我需要顶部的注释为Wordpress.

*/
Theme Name: Forum
Theme URI: 
Description: 
Author:
Author URI: 
Version: 1.0
Tags:
/*
Run Code Online (Sandbox Code Playgroud)

我可以使用横幅添加评论吗?

sass: {
  dist: {
    options: {
      banner:
      '
      */
      Theme Name: Forum
      Theme URI: 
      Description: 
      Author:
      Author URI: 
      Version: 1.0
      Tags:
      /*
      '
    },
    files: {
      "src/php/wp-content/themes/forum/style.css": "src/sass/forum/output.scss"
    }
  }
},
Run Code Online (Sandbox Code Playgroud)

wordpress sass gruntjs

1
推荐指数
1
解决办法
785
查看次数

Grunt:更新YAML文件中的值?

我正在处理我的buildscript,我需要更新YAML(.yml准确)文件中的值.

为了便于开发,我只是将其定义为我的默认任务:

grunt.registerTask('default', function() {
    var conf = grunt.file.readYAML('config.yml');

    // Shows correct contents of config.yml
    console.log(conf);

    // Changing the value of key 'deploy'
    conf['deploy'] = 'Hello World';

    // Trying to write the updated data back to file
    grunt.file.write('config.yml', conf);

    // Re-reading the new file
    var conf2 = grunt.file.readYAML('config.yml');

    // logs [ 'object Object' ]
    console.log(conf2);
});
Run Code Online (Sandbox Code Playgroud)

我想我的评论非常清楚我想要做什么 - 更新配置设置.

[ 'object Object' ]记录的原因是因为它实际写入该文件.这意味着我不能简单地做grunt.file.write('config.yml', conf);,我需要像JSON.stringifyYAML 一样的东西.这样的事情存在吗?如何在Grunt中更新yml文件中的值?

javascript yaml gruntjs

1
推荐指数
1
解决办法
976
查看次数

转发grunt连接到不同的URL

我正在使用grunt连接livereload用于我的开发环境.

我希望能够调用/ server下的生产API.

要做到这一点,我需要指挥任何来电

http://localhost:9000/server

http://www.production-server.com/server

这对我有好处,因为有时我想在开发模式下对生产服务器进行测试.

这是我当前的连接配置(由Yeoman生成):

connect: {
  options: {
    port: 9000,
    // Change this to '0.0.0.0' to access the server from outside.
    hostname: 'localhost',
    livereload: 35729
  },
  livereload: {
    options: {
      open: true,
      middleware: function(connect, options, middlewares) {
        return [
          connect.static('.tmp'),
          connect().use(
            '/bower_components',
            connect.static('./bower_components')
          ),
          connect.static(appConfig.app)
        ];
      }
    }
  },
  test: {
    options: {
      port: 9001,
      middleware: function(connect) {
        return [
          connect.static('.tmp'),
          connect.static('test'),
          connect().use(
            '/bower_components',
            connect.static('./bower_components')
          ),
          connect.static(appConfig.app)
        ];
      }
    }
  },
  dist: {
    options: { …
Run Code Online (Sandbox Code Playgroud)

node.js gruntjs grunt-contrib-connect

1
推荐指数
1
解决办法
2420
查看次数

使用grunt在javascript文件中"嵌入"一个全局变量

我的项目中有一个.js文件,代码如下:

var API_ENDPOINT = 'http://example.com:8000';
var api = new RemoteApi(API_ENDPOINT);
Run Code Online (Sandbox Code Playgroud)

其中API_ENDPOINT开发/ PROD环境之间的变化

它不是一个js应用程序,主要是一个经典的服务器端应用程序(Django),它有一些客户端的内容.

我开始使用Grunt来管理客户端依赖关系并认为,API_ENDPOINT在Grunt配置中指定并以某种方式将其"嵌入"到.js文件中是个好主意.

但是我找不到用Grunt破坏文件的方法.

生成的.js文件将在浏览器envorenment中运行,因此我需要API_ENDPOINT在source.js文件中嵌入我的变量或创建一个单独的.js文件,如

var API_ENDPOINT = '...';
Run Code Online (Sandbox Code Playgroud)

我将在script.js之前包含哪些内容

(另外,我想把这个变量"嵌入"我的django中settings.py)

javascript gruntjs

1
推荐指数
1
解决办法
923
查看次数