Error when executing npm run grunt default?

0

I have the following files for the GruntJS configuration and thus pass my js files to js.min files

The package.json file:

  {
  "name": "grunt-primerospasos",
  "version": "1.0.0",
  "description": "Descripcion de mi primer proyecto en gruntjs",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://gitlab.com/jggj/grunt-primerospasos.git"
  },
  "keywords": [
    "gruntJS"
  ],
  "author": "jggarcia",
  "license": "ISC",
  "bugs": {
    "url": "https://gitlab.com/jggj/grunt-primerospasos/issues"
  },
  "homepage": "https://gitlab.com/jggj/grunt-primerospasos#README",
  "devDependencies": {
    "grunt": "^1.0.1",
    "grunt-contrib-uglify": "^3.1.0"
  },
  "dependencies": {
    "grunt-contrib-uglify": "^3.1.0",
    "grunt": "^1.0.1"
  }
}

and the Gruntfile.js file, like this:

    module.exports = function (grunt) {
    //Configuraciones del proyecto
    grunt.initConfig({
        //Conf Uglify
        uglify: {
            options: {
                mangle: false,
                compress: {
                    drop_console: true
                }
            },
            js: {
                files:[{
                    cwd: 'js/src/', //ruta de nuestro javascript fuente
                    expand: true,   //ingresar a las subcarpetas
                    src: '*.js'     //patrón relativo a cwd
                    dest: 'js/min/' //destino de los archivos compresos, minificados
                }]
            }
        }
    });

//Cargar grunt-contrib-uglify (plugin)
grunt.loadNpmTasks('grunt-contrib-uglify');

//Registrar la tarea default, esta ejecutara la tarea grunt uglify
grunt.registerTask('default',['uglify']);

};

When I run the npm run grunt default command it gives me the following error:

    npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start"
npm ERR! node v6.11.3
npm ERR! npm  v3.10.10

npm ERR! missing script: start
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     C:\xampp\htdocs\grunt-primerospasos\npm-debug.log

and in the end I can not convert my js files to minified ones. What could be my mistake?

    
asked by JG_GJ 19.09.2017 в 07:05
source

3 answers

1
  

When I run the npm run grunt default command it gives me the following error:

The command that you have to execute is grunt default

  

grunt default   Running "uglify: js" (uglify) task

     
    

No files created.     Done.

  

It will also work for you if you run grunt , as it performs the default

task by default     
answered by 19.09.2017 / 10:34
source
0

Person who does not help you enough, you have to edit this code in some way:

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
},

The safest thing is that if you run npm test you will see that text and it will leave the terminal.

    
answered by 19.09.2017 в 07:21
0

Most likely, you do not have the "start" script defined as the error says:

"scripts": {
    "start": "node your-script.js"
}

What happens is that you need to start a server node to use grunt, you can take a look here .

    
answered by 19.09.2017 в 08:52