search

Home  >  Q&A  >  body text

node.js - cnpm使用出错

/usr/local/lib/node_modules/cnpm/node_modules/npminstall/bin/install.js:17
const debug = require('debug')('npminstall:bin:install');
^^^^^
SyntaxError: Use of const in strict mode.
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
黄舟黄舟2781 days ago557

reply all(3)I'll reply

  • 怪我咯

    怪我咯2017-04-17 13:41:02

    What is the Node.js version? Try upgrading to v4 or v5, or use npm i --registry=https://registry.npm.taobao.org

    directly

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:41:02

    node --version
    Check the version of your node. If it is too low, it may not support the const variable declaration method, because this is the syntax of es6

    reply
    0
  • 黄舟

    黄舟2017-04-17 13:41:02

    It should be that the node version is too low. It is recommended to use NVM to manage the node version:

    $ git clone git@github.com:creationix/nvm.git ~/.nvm
    $ source ~/.nvm/nvm.sh
    # 安装
    $ nvm install v0.12.0
    # 显示当前本地安装的所有 Node.js
    $ nvm ls 
    # 显示服务器所有可用的 Node.js
    $ nvm ls-remote
    # 本地可用的 Node.js 中使用 0.12.0
    $ nvm use 0.12.0
    # 设置每次启动默认版本
    $ nvm alias default 0.12.0

    In addition, nvm install node you can install the latest node.

    reply
    0
  • Cancelreply