2016-11-26 57 views
1

大家好我想更新npm和安裝在我的mac上的節點版本,但我不斷收到此錯誤。有人可以幫助我理解和解決這個問題,因爲我對這個特定問題缺乏多少知識,應該如何處理。錯誤如下所示,任何幫助將不勝感激。如何解決module.js:442錯誤

npm update 
module.js:442 
    throw err; 
    ^

Error: Cannot find module 'are-we-there-yet' 
    at Function.Module._resolveFilename (module.js:440:15) 
    at Function.Module._load (module.js:388:25) 
    at Module.require (module.js:468:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:2:16) 
    at Module._compile (module.js:541:32) 
    at Object.Module._extensions..js (module.js:550:10) 
    at Module.load (module.js:458:32) 
    at tryModuleLoad (module.js:417:12) 
    at Function.Module._load (module.js:409:3) 

這裏是我的log.js文件供參考我應該怎樣解決這個問題?

'use strict' 
var Progress = require('are-we-there-yet') 
var Gauge = require('gauge') 
var EE = require('events').EventEmitter 
var log = exports = module.exports = new EE() 
var util = require('util') 

var setBlocking = require('set-blocking') 
var consoleControl = require('console-control-strings') 

setBlocking(true) 
var stream = process.stderr 
Object.defineProperty(log, 'stream', { 
    set: function (newStream) { 
    stream = newStream 
    if (this.gauge) this.gauge.setWriteTo(stream, stream) 
    }, 
    get: function() { 
    return stream 
    } 
}) 

也可對照以下

{ 
    "_args": [ 
    [ 
     { 
     "raw": "[email protected]", 
     "scope": null, 
     "escapedName": "npmlog", 
     "name": "npmlog", 
     "rawSpec": "4.0.0", 
     "spec": "4.0.0", 
     "type": "version" 
     }, 
     "/Users/zkat/Documents/code/npm" 
    ] 
    ], 
    "_from": "[email protected]", 
    "_id": "[email protected]", 
    "_inCache": true, 
    "_location": "/npm/npmlog", 
    "_nodeVersion": "5.10.1", 
    "_npmOperationalInternal": { 
    "host": "packages-12-west.internal.npmjs.com", 
    "tmp": "tmp/npmlog-4.0.0.tgz_1468888150556_0.3835553650278598" 
    }, 
    "_npmUser": { 
    "name": "zkat", 
    "email": "[email protected]" 
    }, 
    "_npmVersion": "3.10.4", 
    "_phantomChildren": { 
    "aproba": "1.0.4", 
    "has-unicode": "2.0.1", 
    "readable-stream": "2.1.5", 
    "strip-ansi": "3.0.1" 
    }, 
    "_requested": { 
    "raw": "[email protected]", 
    "scope": null, 
    "escapedName": "npmlog", 
    "name": "npmlog", 
    "rawSpec": "4.0.0", 
    "spec": "4.0.0", 
    "type": "version" 
    }, 
    "_requiredBy": [ 
    "/npm" 
    ], 
    "_resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.0.0.tgz", 
    "_shasum": "e094503961c70c1774eb76692080e8d578a9f88f", 
    "_shrinkwrap": null, 
    "_spec": "[email protected]", 
    "_where": "/Users/zkat/Documents/code/npm", 
    "author": { 
    "name": "Isaac Z. Schlueter", 
    "email": "[email protected]", 
    "url": "http://blog.izs.me/" 
    }, 
    "bugs": { 
    "url": "https://github.com/npm/npmlog/issues" 
    }, 
    "dependencies": { 
    "are-we-there-yet": "~1.1.2", 
    "console-control-strings": "~1.1.0", 
    "gauge": "~2.6.0", 
    "set-blocking": "~2.0.0" 
    }, 
    "description": "logger for npm", 
    "devDependencies": { 
    "standard": "~7.1.2", 
    "tap": "~5.7.0" 
    }, 
    "directories": {}, 
    "dist": { 
    "shasum": "e094503961c70c1774eb76692080e8d578a9f88f", 
    "tarball": "https://registry.npmjs.org/npmlog/-/npmlog-4.0.0.tgz" 
    }, 
    "files": [ 
    "log.js" 
    ], 
    "gitHead": "3ca8823fdfa66f54c72adde3fd2c4e0237e6302b", 
    "homepage": "https://github.com/npm/npmlog#readme", 
    "license": "ISC", 
    "main": "log.js", 
    "maintainers": [ 
    { 
     "name": "iarna", 
     "email": "[email protected]" 
    }, 
    { 
     "name": "isaacs", 
     "email": "[email protected]" 
    }, 
    { 
     "name": "othiym23", 
     "email": "[email protected]" 
    }, 
    { 
     "name": "zkat", 
     "email": "[email protected]" 
    } 
    ], 
    "name": "npmlog", 
    "optionalDependencies": {}, 
    "readme": "ERROR: No README data found!", 
    "repository": { 
    "type": "git", 
    "url": "git+https://github.com/npm/npmlog.git" 
    }, 
    "scripts": { 
    "test": "standard && tap test/*.js" 
    }, 
    "version": "4.0.0" 
} 
+0

您正在嘗試更新節點版本或軟件包的版本? npm更新更新你的包是不是你的節點版本 –

+0

@HugoFarji是的,基本上npm包,然後節點版本,但這個錯誤是不允許我做任何,我甚至不能安裝新的包,由於這個錯誤 – bmalhi

+0

你可以告訴我們你的包。 json文件? –

回答

1

該文件的package.json我只是去到/ usr/local/lib目錄/文件夾中刪除所有的節點和node_module文件夾解決我的問題。之後,我再次下載了節點,這對我有用,我可以安裝和更新npm軟件包。