【问题标题】:NPM cannot find module bashNPM 找不到模块 bash
【发布时间】:2017-12-18 01:42:03
【问题描述】:

我已安装和卸载节点,但无法正常工作。

当我输入 node -v 时,我会返回版本,但如果我输入 npm -v,我会收到此错误

module.js:544
    throw err;
    ^

Error: Cannot find module '../lib/utils/unsupported.js'
    at Function.Module._resolveFilename (module.js:542:15)
    at Function.Module._load (module.js:472:25)
    at Module.require (module.js:585:17)
    at require (internal/module.js:11:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:92:3)
    at Module._compile (module.js:641:30)
    at Object.Module._extensions..js (module.js:652:10)
    at Module.load (module.js:560:32)
    at tryModuleLoad (module.js:503:12)

虽然可能不相关,但我最近开始使用 gulp.js 并且问题开始出现。

【问题讨论】:

    标签: node.js bash npm terminal command-line-interface


    【解决方案1】:

    您的 npm node_modules 包可能存在一些权限错误。

    只需删除您的node_modules 文件夹,然后重新安装节点。

    清除全局节点模块

    rm -rf /usr/local/lib/node_modules/
    

    重新安装 Node 和 npm

    brew install node
    

    或使用节点安装程序下载安装:https://nodejs.org/en/download/

    要查看是否安装了 Node,请输入 node -v in Terminal。这应该打印版本号。

    要查看是否安装了 NPM,请在终端中输入 npm -v。这应该打印版本号。

    【讨论】:

    • :( Trent now node -v 不起作用和 npm -v 。情况变得更糟了。
    • 很抱歉。我现在是移动设备,但是您可以尝试现在运行第一个命令来卸载节点模块,然后使用 nodejs.org 网站上的可安装包进行安装吗?
    • 注意,您可能需要重新启动终端才能通过命令行访问软件包。
    • 为了保存!使用 nodejs.org 通过将 bash 命令添加到我的本地/bin 文件夹为我完成了它,因为它丢失了。
    • @Justin,我已编辑我的答案以包含此解决方案。感谢“接受的答案”!
    猜你喜欢
    • 1970-01-01
    • 2016-06-17
    • 2014-08-24
    • 2015-12-16
    • 2016-04-29
    • 2014-11-18
    • 2015-01-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多