CNode

ubuntu 和win nodejs

问答
Yyundian发布于10 年前最后回复10 年前8 回复4421 浏览0 收藏

我在win下开发的文件可以运行复制到ubuntu 下就报错 报错如下 /home/ubuntu/site/node_modules/connect-mongo/src/index.js:3 const Promise = require('bluebird'); ^^^^^ 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 Module.require (module.js:364:17) at require (module.js:380:17) at Object. (/home/ubuntu/site/node_modules/connect-mongo/index.js:1:80) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32)

查看回复

回复 (8)

C
Chunlin-Li#1·10 年前

检查 node js 版本. 运行参数. js 文件首行加没加 'use strict'

Y
yundian#2·10 年前
引用 Chunlin-Li检查 node js 版本. 运行参数. js 文件首行加没加 'use strict'

@Chunlin-Li 直接使用express 模板做的,在win在没问题,node版本有关吗?win和ubuntu都是最新的呀

Y
yundian#3·10 年前
C
Chunlin-Li#4·10 年前

const 是 ES6 引入的特性. 错误提示已经很清楚的告诉你要使用 strict 模式了.
你在 Win 上可以运行我不知道是什么情况.
本人愚钝, 但建议你把两边的 Node 版本, 以及你使用 Node 启动服务时的命令行都给出来, 方便其他高手给你解答.

Y
yundian#6·10 年前

nodejs win版本5.7.1 ubuntu 5.7.1 mongodb win版本 3.0.6 ubuntu2.6.10

I
iyuq#7·10 年前

你不会把node_modules直接复制过去的吧,要删了用npm重新安装

来自酷炫的 CNodeMD

Y
yundian#8·10 年前
引用 iyuq你不会把node modules直接复制过去的吧,要删了用npm重新安装 来自酷炫的 CNodeMD

@iyuq 你猜对了。。。感觉应该是你说的原因谢谢,一语中的

参与回复
登录后即可参与回复。登录