升级Ubuntu后现在发生Node.js错误

时间:2019-06-01 06:11:17

标签: node.js vagrant virtualbox ubuntu-14.04 ubuntu-16.04

我正在使用VirtualBox和Vagrant在Windows 10上构建Ubuntu的虚拟环境。

昨天从Ubuntu 14.04更新到Ubuntu 16.04.6 LTS之后,运行node.js时发生错误。

尝试按如下方式启动Web应用程序时出现错误:

$ PORT=8000 npm start

/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:57
log.progressEnabled = log.gauge.isEnabled()
                                ^

TypeError: log.gauge.isEnabled is not a function
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:57:33)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:681:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:22:13
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:152:3)
    at Module._compile (internal/modules/cjs/loader.js:774:30)

在Ubuntu版本升级之前未发生此错误。

如何解决此错误?


我尝试了以下操作,但效果不佳。

$ rm -rf node_modules
$ npm install --reset-cache
/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:57
log.progressEnabled = log.gauge.isEnabled()
                                ^

TypeError: log.gauge.isEnabled is not a function
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:57:33)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:681:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:22:13
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:152:3)
    at Module._compile (internal/modules/cjs/loader.js:774:30)

1 个答案:

答案 0 :(得分:1)

尝试删除node_modules并运行npm install --reset-cache希望对您有所帮助