CNPM 遇到use strict的问题

一、问题描述

[root@VM_123_144_centos node01]# cnpm install --save nodemailer

/usr/lib/node_modules/cnpm/node_modules/npminstall/bin/install.js:5
const debug = require('debug')('npminstall:bin:install');
^^^^^
SyntaxError: Use of const in strict mode.
    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:929:3

二、解决办法
删除node_modules文件夹

[root@VM_123_144_centos node01]# rm -rf /usr/lib/node_modules 

使用NVM重新安装最新版的nodejs

nvm install node

安装成功后,查看版本

[root@VM_123_144_centos node01]# nvm install node
v6.4.0 is already installed.
Now using node v6.4.0
[root@VM_123_144_centos node01]# node -v
v6.4.0

测试cnpm

[root@VM_123_144_centos node01]# npm install --save express
hello@1.0.0 /root/node01
`-- express@4.14.0 
  +-- accepts@1.3.3 
  | +-- mime-types@2.1.11 
  | | `-- mime-db@1.23.0 
  | `-- negotiator@0.6.1 
  +-- array-flatten@1.1.1 
  +-- content-disposition@0.5.1 
  +-- content-type@1.0.2 
  +-- cookie@0.3.1 
  +-- cookie-signature@1.0.6 
  +-- debug@2.2.0 
  | `-- ms@0.7.1 
  +-- depd@1.1.0 
  +-- encodeurl@1.0.1 
  +-- escape-html@1.0.3 
  +-- etag@1.7.0 
  +-- finalhandler@0.5.0 
  | +-- statuses@1.3.0 
  | `-- unpipe@1.0.0 
  +-- fresh@0.3.0 
  +-- merge-descriptors@1.0.1 
  +-- methods@1.1.2 
  +-- on-finished@2.3.0 
  | `-- ee-first@1.1.1 
  +-- parseurl@1.3.1 
  +-- path-to-regexp@0.1.7 
  +-- proxy-addr@1.1.2 
  | +-- forwarded@0.1.0 
  | `-- ipaddr.js@1.1.1 
  +-- qs@6.2.0 
  +-- range-parser@1.2.0 
  +-- send@0.14.1 
  | +-- destroy@1.0.4 
  | +-- http-errors@1.5.0 
  | | +-- inherits@2.0.1 
  | | `-- setprototypeof@1.0.1 
  | `-- mime@1.3.4 
  +-- serve-static@1.11.1 
  +-- type-is@1.6.13 
  | `-- media-typer@0.3.0 
  +-- utils-merge@1.0.0 
  `-- vary@1.1.0 

npm WARN hello@1.0.0 No repository field.

==================Enjoy it================

posted @ 2016-09-09 14:55  shugen  阅读(664)  评论(0编辑  收藏  举报