Node.js cannot find module x

Here is some diagnostic checks you can try if your using Node.js and it reports that it “cannot find module x”. These commands are obviously relative to what packages your using.

Possible causes & solutions

Not installing node packages globally, use the -g flag in the following command.

npm install grunt -g

NODE_PATH is not set. Check by typing $NODE_PATH, set by typing the following command.

NODE_PATH=<path to your node_modules folder>

npm packages need updating, run the following command to update your npm packages.

npm update

Missing grunt-cli, install it using the following command. substitute grunt-cli for .

npm install grunt-cli -g

If all else fails bang your head against the wall… repeatedly…