My M.O. in web development is “When it doubt, panic.” Exactly, what I did a few minutes ago before writing this.
While setting up a local WordPress install, I ran into an error message, produced when I tried to run an ‘npm’ command. After googling every error message I ran into, I finally resolved it. Here’s how:
My first issue began when I ran ‘npm install’ and got this error message:
SyntaxError: Use of const in strict mode.
I followed the second set instructions here: http://stackoverflow.com/questions/22603078/syntaxerror-use-of-const-in-strict-mode as they were concise and easy to follow. Not knowing exactly what a “helper” is and while in a panic thinking I’ve hosed my setup, I ran the command.
I then upgraded node to v7.8.0 hoping that would fix it but I was met with a new round of errors instead:
npm Error: invalid version install
Now, I was certain I was making the situation worse.
I tried going back into my theme and running npm there when I was met with:
Cannot find module 'internal/fs'
After searching, I found this: https://github.com/npm/npm/issues/14232 where I got the impression I should downgrade Node.
Next, I searched how to remove node and reinstall it. I found this where I followed the first poster’s set of instructions: http://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x
I ran
npm -v
and saw 3.10.10
I took note of the progress and allowed myself to calm down a little.
npm install gulp
ran smoothly except for a warning message to update graceful-fs as soon as possible. However, when I ran the gulp command, I saw this: -bash: gulp: command not found
This time stackoverflow helped me out big time with this gem: http://stackoverflow.com/questions/25090452/gulp-command-not-found-after-install
I ran npm config set prefix /usr/local,
went back to my theme and ran gulp
Just when you think you’ve solved it…
Run `npm rebuild node-sass` to build the binding for your current environment.
I ran the command, ran gulp
and… Viola Davis!
Problem solved! Such a relief I can work again!
This post was mainly to gloat over my small victory but also as a reminder to myself to breathe when I run into problems.
Leave a Reply