kong-dashboard start“没有这个目录”的错误 && 升级了npm nodejs版本过低 无法使用npm的问题

最近在配置kong的时候 下载了kong管理端的第三方网页kong-dashboard
但是在启动kong-dashboard的时候发生了“没有这个目录”这个错误
后来发现是node的版本不够
上网查安装npm 升级npm

sudo npm install npm@latest -g

然后就悲剧了。。因为node版本过低 而npm却升级了导致npm起不了了

$sudo npm install -g n

/usr/local/lib/node_modules/npm/bin/npm-cli.js:79
      let notifier = require('update-notifier')({pkg})
          ^^^^^^^^
SyntaxError: Unexpected identifier
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3

在网上找了很久 终于找到了解答https://segmentfault.com/a/1190000007542620

过程

1.先将刚刚升级的npm移除 在/usr/local/lib/node_modules目录下

$ sudo mv npm/ /tmp/usr_local_lib_node_modules_npm

2.使用npm安装n 再通过n来安装稳定版本

$sudo npm install -g n 
npm http GET https://registry.npmjs.org/n
npm http 304 https://registry.npmjs.org/n
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
n@2.1.12 /usr/local/lib/node_modules/n
$sudo n stable

     install : node-v10.6.0
       mkdir : /usr/local/n/versions/node/10.6.0
       fetch : https://nodejs.org/dist/v10.6.0/node-v10.6.0-linux-x64.tar.gz
######################################################################## 100.0%
   installed : v10.6.0

好了 终于把npm和node升级完了 kong-dashborad也能正常跑了!

猜你喜欢

转载自blog.csdn.net/zkt286468541/article/details/81022967