Fixing TypeError: Object #<Queue> has no method ‘replace’

While attempting to get Shifter to work on my laptop I ran into the following error. The fix is below.

By day I am a humble Moodle developer. Moodle uses YUI Shifter to bundle up its Javascript. Shifter seems to work happily for everyone else but I am recording this here for when it next doesn’t work for me.

When doing anything Shifter related I was getting the below.

TypeError: Object #<Queue> has no method ‘replace’
at Object.buildJS [as js] (/usr/local/lib/node_modules/shifter/lib/module.js:324:11)
at /usr/local/lib/node_modules/shifter/lib/module.js:690:21
at /usr/local/lib/node_modules/shifter/lib/stack.js:24:38
at CB (/usr/local/lib/node_modules/shifter/node_modules/rimraf/rimraf.js:42:5)
at /usr/local/lib/node_modules/shifter/node_modules/rimraf/rimraf.js:61:16
at Object.oncomplete (fs.js:97:15)

Googling that error led me to That explains the problem but how exactly do I fix it… Just making that file change on its own doesn’t do anything… Making the change then re-installing Shifter just resets that file… After some trial and error I fixed it like this.

  1. Find Shifter’s package.json. For me its at /usr/local/lib/node_modules/shifter. If you aren’t sure where it is, note that the path is in the error message 😉
  2. Change the required gear version as shown in the commit of that github pull
  3. In the Shifter directory run npm update
  4. Get on with the actual work that you are meant to be doing.

2 thoughts on “Fixing TypeError: Object #<Queue> has no method ‘replace’

Leave a Reply