Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
';模块';在grunt javascript中未定义_Javascript_Gruntjs_Build Script - Fatal编程技术网

';模块';在grunt javascript中未定义

';模块';在grunt javascript中未定义,javascript,gruntjs,build-script,Javascript,Gruntjs,Build Script,我想在我的java脚本项目中集成Grunt。我已经安装了npm、grunt等 我已经为grunt创建了package.json文件和GRUNTFILE.js 但是当我运行“grunt”命令时,我得到的错误是“module”未定义 Grunfile.js module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json') }); grun

我想在我的java脚本项目中集成Grunt。我已经安装了npm、grunt等

我已经为grunt创建了package.json文件和GRUNTFILE.js

但是当我运行“grunt”命令时,我得到的错误是“module”未定义

Grunfile.js

module.exports = function(grunt) {

  grunt.initConfig({
        pkg: grunt.file.readJSON('package.json')
    });

    grunt.registerTask('default', []);



};
Package.json

{
  "name": "Example",
  "version": "0.0.1",
  "private": true,
  "devDependencies": {
    "grunt": "latest",
    "grunt-cli": "^0.1.13"
  }
}

运行以下命令后,我成功地在我的项目上运行grunt

  • npm卸载

  • npm安装-g grunt cli(全局安装)

  • npm安装(在项目目录上)


  • 在运行第三个项目之前,该项目必须包含“packge.json”和gruntfile.js文件。

    我也遇到了这个问题,我发现确保将grunt文件正确命名为
    gruntfile.js
    修复了我的问题,愚蠢但可以忽略。

    听起来您并没有实际运行Node。Node正在计算机上运行。您是否在存储grunt配置文件的目录中运行了“npm install”?是的,我在项目目录中运行了“npm install”,但错误仍然相同。