Running OSX el capitan 10.11.3
Recently returned to Node development (after about 3 months) only to find that Nodemon no longer runs on my system. For example, executing the following command:
nodemon -v
Will return this error stack:
module.js:341
throw err;
^
Error: Cannot find module 'got'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/usr/local/lib/node_modules/nodemon/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js:2:11)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
I have tried reinstalling nodemon and reinstalled node.js entirely.
npm uninstall -g nodemon
npm install -g nodemon
I don't see any dependency for 'got' in package.json at /usr/local/lib/node_modules/nodemon
{
"name": "nodemon",
"homepage": "http://nodemon.io",
"author": {
"name": "Remy Sharp",
"url": "http://github.com/remy"
},
"bin": {
"nodemon": "./bin/nodemon.js"
},
"engines": {
"node": ">=0.8"
},
"repository": {
"type": "git",
"url": "git+https://github.com/remy/nodemon.git"
},
"description": "Simple monitor script for use during development of a node.js app.",
"keywords": [
"monitor",
"development",
"restart",
"autoload",
"reload",
"terminal"
],
"preferGlobal": "true",
"license": "MIT",
"main": "./lib/nodemon",
"scripts": {
"coverage": "istanbul cover _mocha -- --timeout 30000 --ui bdd --reporter list test/**/*.test.js",
"lint": "jscs lib/**/*.js -v",
":spec": "mocha --timeout 30000 --ui bdd test/**/*.test.js",
"test": "npm run lint && npm run spec",
"spec": "for FILE in test/**/*.test.js; do echo $FILE; ./node_modules/.bin/mocha --timeout 30000 $FILE; if [ $? -ne 0 ]; then exit 1; fi; sleep 1; done",
"web": "node web",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"devDependencies": {
"async": "1.4.2",
"coffee-script": "~1.7.1",
"connect": "~2.19.1",
"istanbul": "~0.2.10",
"jscs": "2.1.1",
"mocha": "2.3.3",
"should": "~4.0.0",
"semantic-release": "4.3.5"
},
"dependencies": {
"chokidar": "^1.2.0",
"debug": "^2.2.0",
"es6-promise": "^3.0.2",
"lodash.defaults": "^3.1.2",
"minimatch": "^3.0.0",
"ps-tree": "^1.0.1",
"touch": "1.0.0",
"undefsafe": "0.0.3",
"update-notifier": "0.5.0"
},
"version": "1.8.1",
"gitHead": "b292ae74b7c43407a52ce2d33d36ff218f4245ed",
"bugs": {
"url": "https://github.com/remy/nodemon/issues"
},
"_id": "nodemon@1.8.1",
"_shasum": "75cfd7ac167e938cdab7313c839bc45a1859bb32",
"_from": "nodemon@*",
"_npmVersion": "2.14.9",
"_nodeVersion": "4.2.1",
"_npmUser": {
"name": "remy",
"email": "remy@leftlogic.com"
},
"dist": {
"shasum": "75cfd7ac167e938cdab7313c839bc45a1859bb32",
"tarball": "http://registry.npmjs.org/nodemon/-/nodemon-1.8.1.tgz"
},
"maintainers": [
{
"name": "remy",
"email": "remy@remysharp.com"
}
],
"directories": {},
"_resolved": "https://registry.npmjs.org/nodemon/-/nodemon-1.8.1.tgz"
}
Also here is the nodemon.js file located at usr/local/bin
#!/usr/bin/env node
'use strict';
var cli = require('../lib/cli');
var nodemon = require('../lib/');
var options = cli.parse(process.argv);
nodemon(options);
var fs = require('fs');
// checks for available update and returns an instance
var defaults = require('lodash.defaults');
var pkg = JSON.parse(fs.readFileSync(__dirname + '/../package.json'));
require('update-notifier')({
pkg: defaults(pkg, { version: '0.0.0' }),
}).notify();
I recently followed this answer from user Passy to gain permissions over my globally installed packages with these two commands:
echo 'prefix = ~/.node' >> ~/.npmrc
export PATH="$PATH:$HOME/.node/bin"
And here are the top few lines of my .bash_profile
export PATH=/usr/bin:/usr/sbin:/bin:/sbin:$PATH
export PATH="$PATH:$HOME/.node/bin"
Does it even make sense to have two lines there? Fairly novice coder here so I apologize in advance. Have searched pretty extensively for a solution on this one and I can't find anything that works so here goes! Will check in periodically to edit the question.
Here is a hack that could help (npm3 may have missed a dependency):
cd /usr/local/lib/node_modules/nodemon
npm install got