node.js - 升级 Ubuntu 后会出现 Node.js 错误
问题描述
我正在使用 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)
解决方案
try removing node_modules and run npm install --reset-cache
hope that helps
推荐阅读
- javascript - 使用 JavaScript 检查时将复选框/单选标签设为粗体
- javascript - 我想在文本冒险中实现一个健康栏
- angular - Angular 12 将 json 导入 ts
- c++ - 如何使用其版本查找所有依赖项(静态和动态链接)
- c - 有没有办法在堆上自动分配结构?
- excel - VBA:基于计时器的条件格式单元格颜色及其自身条件
- c - 搜索 arr 是否在二进制文件中 c
- python - 检查完整性和最新版本 - Pandas Dataframe
- javascript - 将 div 设为列表项,div 没有相同的父项
- colors - 比较十进制的十六进制颜色