Cannot setup/run Grunt

Cannot setup/run Grunt

by Taylor Chadwick -
Number of replies: 1

Hello,

I am new to moodle development and I have a new moodle block that I'm working on. This block needs some AJAX calls to dynamically load a select dropdown, easy. Look at the documentation, see that I need a webservice and some JavaScript to trigger the AJAX call. I follow the documentation to install grunt (which I'm new at), grab their helloworld.js file example and nothing. I am unable to uglify the js file. I get this error. 

>> Uglifying source amd/src/helloworld.js failed.

Warning: Uglification failed.

Unexpected token: name «Str», expected: punc «;».

Line 8 in amd/src/helloworld.js

 Use --force to continue.

Aborted due to warnings.


The line it is complaining about is at the top of the helloworld.js file found  https://docs.moodle.org/dev/Javascript_Modules#.22Hello_World.22_I_am_a_Javascript_Module

import * as Str from 'core/str';

I tried to delete this line but the uglify still fails probably because the js uses it. Im at my wits end with this issue. I dont know where to even start if the documentation is no longer helpful. They show some commands to use with grunt in the docs but they dont work either. Any one got any ideas?

Average of ratings: -
In reply to Taylor Chadwick

Re: Cannot setup/run Grunt

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
This is not my strongest area, but using:
  • Moodle 3.10+ ?
  • Linux?

Checked that the line endings are LF?  File is encoded in UTF8?