在centos上使用sequelize安装nodejs时出错



这是我的nodejs版本:6.17.1和sequelize 6.4.0。我遵循这个:https://bezkoder.com/react-node-express-mysql/。我得到了error:

> /app/nodejs/node_modules/sequelize/lib/sequelize.js:277
>       ...options
> SyntaxError: Unexpected token ...
>     at createScript (vm.js:56:10)
>     at Object.runInThisContext (vm.js:97:10)
>     at Module._compile (module.js:549:28)
>     at Object.Module._extensions..js (module.js:586:10)
>     at Module.load (module.js:494:32)
>     at tryModuleLoad (module.js:453:12)
>     at Function.Module._load (module.js:445:3)
>     at Module.require (module.js:504:17)
>     at require (internal/module.js:20:19)
>     at Object.<anonymous> (/app/nodejs/node_modules/sequelize/index.js:8:18)

我错了吗?

用这个代码解决:

+ sudo yum install nodejs
+ node --version
+ npm --version
+ which node
+ which npm
+ curl -sL https://rpm.nodesource.com/setup_12.x | bash -
+ ls -la /etc/yum.repos.d/|grep nodesource
+ sudo yum remove -y nodejs npm
+ sudo yum list available nodejs
+ sudo yum install nodejs
+ node --version
+ npm --version

信用:https://matthiashoys.wordpress.com/2020/01/15/how-to-upgrade-node-js-from-v6-to-v12-on-centos-linux-7/

您的节点版本不支持扩展操作符(…)。你需要8.6以上的版本。

点击这个链接,在节点中找到具体的支持方法,https://node.green/#ES2015

最新更新