1

Already follow from this dev document this

1.npm install -g grunt-cli

2.Rename 3 files - package.json.sample into package.json - Gruntfile.js.sample into Gruntfile.js - grunt-config.json.sample into grunt-config.json

3.cd your_Magento_instance_directory npm install npm update

4.adding themes in dev/tools/grunt/configs themes.js

 default: {
    area: 'frontend',
    name: 'Tutor/default',
    locale: 'en_US',
    files: [
        'css/styles-m',
        'css/styles-l'
    ],
    dsl: 'less'
}

however Im using linux ubuntu 16.0, Im running command grunt in magento root folder

Loading "Gruntfile.js" tasks...ERROR

Error: Cannot find module '/home/user/www/tutor/dev/tools/grunt/configs/local-themes' Warning: Task "default" not found. Use --force to continue.

Aborted due to warnings.

anybody know about this error.

Thanks

4
  • Could you please mentioned the command you are running.
    – Saphal Jha
    Commented May 8, 2019 at 4:45
  • @SaphalJha in root my magento2 $grunt Commented May 8, 2019 at 4:48
  • Is simple 'grunt' command is working? Commented May 8, 2019 at 5:53
  • i tried $grunt only error Loading "Gruntfile.js" tasks...ERROR >> SyntaxError: Unexpected token { Warning: Task "default" not found. Used --force, continuing. i tried also $grunt --force still same error Commented May 8, 2019 at 5:55

6 Answers 6

1

please check the file "grunt-config.json" file in your project root folder. following code should be there:

{
    "themes": "dev/tools/grunt/configs/local-themes"
}

Also, please check the location /home/user/www/tutor/dev/tools/grunt/configs

There will be the file is "themes.js", please rename it to "local-themes.js"

flush the cache

Please check now and let me now if its working. However, I am sure it will be working for you.

Thanks

1
  • Im already follow your steps still error dude Loading "Gruntfile.js" tasks...ERROR >> SyntaxError: Unexpected token { Warning: Task "default" not found. Use --force to continue. Aborted due to warnings. Commented May 8, 2019 at 6:12
0

Please do not rename this, keep it as default :

grunt-config.json.sample

Now try again, if not working then add --force after your command

3
  • already rename it to default grunt-config.json.sample, in my magento root my command $grunt but still error Loading "Gruntfile.js" tasks...ERROR >> SyntaxError: Unexpected token { Warning: Task "default" not found. Used --force, continuing. Done, but with warnings. already add --force in my command still same $grunt --force Commented May 8, 2019 at 4:57
  • Did you tried above solution.
    – Saphal Jha
    Commented May 8, 2019 at 5:05
  • Im already tried as your suggestion but still error Commented May 8, 2019 at 5:24
0

Define Like this :-

<theme>: {
     area: 'frontend',
     name: '<Vendor>/<theme>',  // app/Design/Frontend/Vendor/Theme/ 
     locale: '<language>',
     files: [
         'css/styles-m',
         'css/styles-l'
     ],
     dsl: 'less'
     }
7
  • already my define as my first description Commented May 8, 2019 at 5:35
  • change "default" to your "theme name" Commented May 8, 2019 at 5:43
  • my theme name is default :D and my vendor is Tutor Commented May 8, 2019 at 5:45
  • re-installing grunt "sudo npm install grunt" Commented May 8, 2019 at 5:56
  • i did re-installing stiil same error Commented May 8, 2019 at 6:00
0

Here is process for installing grunt:

First Rename files from root directory - package.json.sample into package.json - Gruntfile.js.sample into Gruntfile.js

  1. Install NodeJs from https://nodejs.org/
  2. Once you have Node install properly run command: "sudo npm install -g grunt-cli"
  3. Go to your project dir. then run command: "sudo npm install grunt --save-dev"
  4. then: "npm install"
  5. Now run command "grunt"
1
  • 1 already install my node js is v4.2.6 2 already install also mya grunt is grunt-cli v1.3.2 and grunt v1.0.4 3.already running sudo npm install grunt --save-dev and also npm install when running command $grunt error like this - Loading "Gruntfile.js" tasks...ERROR >> SyntaxError: Unexpected token { Warning: Task "default" not found. Use --force to continue. Aborted due to warnings. Commented May 8, 2019 at 6:19
0

Alhamdulillah, my issues solve I just updating my nodejs, because my nodjs before the old one so im updating

  1. sudo npm install -g n
  2. sudo n latest

Done, I can run $grunt , $grunt exec:mytheme

Thanks you all for any sugestion :D

0

The issue I had when I got the "unexpected token" error was because one of the theme/sections in my themes.js or local-themes.js contained a hyphen. For example:

theme-frontend-PS: {
     area: 'frontend',
     name: 'PS/theme-frontend-PS',  // app/Design/Frontend/Vendor/Theme/ 
     locale: '<language>',
     files: [
         'css/styles-m',
         'css/styles-l'
     ],
     dsl: 'less'
 }

This would result in an error. Instead, I renamed "theme-frontend-PS" at the beginning of the block to "PS", but you can leave the actual name of the theme alone. Like this:

PS: {
     area: 'frontend',
     name: 'PS/theme-frontend-PS',  // app/Design/Frontend/Vendor/Theme/ 
     locale: '<language>',
     files: [
         'css/styles-m',
         'css/styles-l'
     ],
     dsl: 'less'
 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.