运行OSX el capitan 10.11.3
最近返回Node开发(大约3个月后)才发现Nodemon不再在我的系统上运行。例如,执行以下命令:
nodemon -v
将返回此错误堆栈:
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)
我尝试重新安装nodemon并完全重新安装node.js.
npm uninstall -g nodemon
npm install -g nodemon
我没有看到任何依赖&#39;得到&#39;在package.json中的/ 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"
}
此处还有位于usr / local / bin
的nodemon.js文件 #!/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();
我最近跟着this answer from user Passy获得了使用以下两个命令对全局安装的软件包的权限:
echo 'prefix = ~/.node' >> ~/.npmrc
export PATH="$PATH:$HOME/.node/bin"
以下是我的.bash_profile的前几行
export PATH=/usr/bin:/usr/sbin:/bin:/sbin:$PATH
export PATH="$PATH:$HOME/.node/bin"
在那里有两条线是否有意义?相当新手编码器,所以我提前道歉。已经广泛搜索了这个问题的解决方案,我找不到任何有用的东西,所以这里去了!将定期检查以编辑问题。
答案 0 :(得分:0)
这是一个可以帮助的黑客(npm3可能错过了依赖):
cd /usr/local/lib/node_modules/nodemon
npm install got