node.js - 咕噜警告 : No source files found

标签 node.js npm gruntjs

我是第一次尝试使用 Grunt。我认为我正确地遵循了安装和使用 Grunt 插件(grunt-text-replace)的说明。 (例如,请参阅 Grunt's pagethe plugin's 。)但是我无法成功运行任何内容 - 相反,我不断收到相同的错误。我一直在根据 Grunt 和插件的说明检查我的代码,但我看不出我做错了什么。

这是我的 package.json 文件:

{
  "name": "brink-prototype",
  "version": "0.0.0",
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-jshint": "~0.1.1",
    "grunt-contrib-nodeunit": "~0.1.2",  
    "grunt-text-replace": "~0.3.2"
  }
}

这是我的 Gruntfile.js:

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    replace: {
      src: ['components/bootstrap/less/navbar.less'],
      dest: 'build/',
      replacements: [{
        from: /\.box-shadow.*$/g,
        to: ''
      }]
    }
  });
  grunt.loadNpmTasks('grunt-text-replace');
  grunt.registerTask('default', ['replace']);
};

当我在命令行中运行“grunt”时,出现以下错误:

Running "replace:src" (replace) task
Warning: No source files found Use --force to continue.    
Aborted due to warnings.

我还使用另一个插件(grunt-regex-replace)尝试了这个过程,并得到了完全相同的错误消息。

我哪里出错了?

更新:

以下是文件结构的相关部分:

  • 项目/
    • Gruntfile.js
    • package.json
    • 组件/
      • Bootstrap /
        • 少/
          • 导航栏.less
    • Node 模块/
      • Grunt/
      • grunt-text-replace/

我一直在尝试从 Gruntfile.js 所在的 project/目录运行命令。

也许我的src中的路径应该相对于其他路径?我不知道。

最佳答案

grunt-text-replace 插件要求您指定一个子任务。

replace: {
  aSubtaskName: {
    src: ['components/bootstrap/less/navbar.less'],
    dest: 'build/',
    replacements: [{
      from: /\.box-shadow.*$/g,
      to: ''
    }]
  }
}

关于node.js - 咕噜警告 : No source files found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16161145/

相关文章:

netbeans - 如何将 GruntJS 与 Netbeans 7.3 集成?

javascript - ReferenceError : Can't find variable: define at . .. 'grunt test' 在 require.js 中使用 jasmine

node.js - 在 Mac : inotify@1. 4.1 中不受支持

npm - 为什么安装Vue CLI后无法启动Vue UI?

node.js - 如何将 aws-sdk 与 node.js 一起使用

node.js - Mongoose 填充架构中虚拟值的引用

npm - 更新到最新的 npm 包时面临 dot-prop 的漏洞安全问题

javascript - 使用 npm 安装 grunt-browser-sync 时出错

javascript - Node JS 处理同一路由的多个 POST 请求

mysql - 为什么我的 React 应用程序(具有 Node 和 mysql 后端)可以在本地运行,但不能在 Heroku 上运行?