大家好,我正在尝试更新npm和Mac上安装的节点的版本,但我一直收到此错误。有人可以帮助我理解和解决该问题,因为我对这个特定问题及其处理方法知之甚少。该错误如下所示,将不胜感激任何帮助。

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
  }
})


还有package.json文件,供参考

{
  "_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"
}

最佳答案

我只是通过转到/ usr / local / lib /文件夹删除了所有的node和node_module文件夹来解决了我的问题。之后,我再次下载了节点,这对我来说很有效,我可以安装和更新npm软件包。

关于node.js - 如何解决module.js:442错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40821799/

10-16 18:20