启动服务报错如下:

Last login: Wed Nov  :: on ttys000
localhost:~ sipeng$ cd /Users/sipeng/Desktop/彭思/2017年学习/Node/myblog
localhost:myblog sipeng$ node /Users/sipeng/Desktop/彭思/2017年学习/Node/myblog/index.js
/Users/sipeng/Desktop/彭思/2017年学习/Node/myblog/models/posts.js:
(function (exports, require, module, __filename, __dirname) { import { populate } from 'mongolass/lib/plugins';
^^^^^^ SyntaxError: Unexpected token import
at createScript (vm.js::)
at Object.runInThisContext (vm.js::)
at Module._compile (module.js::)
at Object.Module._extensions..js (module.js::)
at Module.load (module.js::)
at tryModuleLoad (module.js::)
at Function.Module._load (module.js::)
at Module.require (module.js::)
at require (internal/module.js::)
at Object.<anonymous> (/Users/sipeng/Desktop/彭思/2017年学习/Node/myblog/routes/posts.js::)
at Module._compile (module.js::)
at Object.Module._extensions..js (module.js::)
at Module.load (module.js::)
at tryModuleLoad (module.js::)
at Function.Module._load (module.js::)
at Module.require (module.js::)

报错原因:

Node.js不支持import导入第三方框架,使用require导入即可。

// import { populate } from 'mongolass/lib/plugins';
const populate = require('mongolass/lib/plugins')
const marked = require('marked')
const Post = require('../lib/mongo').Post

Node.js启动服务报错SyntaxError: Unexpected token import的更多相关文章

  1. 『奇葩问题集锦』function * (next){ 执行报错 SyntaxError: Unexpected token *

    这是因为  app.use(function * (){ 语句中有一个 * ,这种方式被称为generator functions ,一般写作function *(){...} 的形式,在此类func ...

  2. js报Uncaught SyntaxError: Unexpected token <错误 解决方法

    js报Uncaught SyntaxError: Unexpected token <错误 解决方法 错因 js被shiro的拦截器拦下,访问不了 #shiro的配置 shiro: hash-a ...

  3. 在CentOS上安装node.js的时候报错:No acceptable C compiler found!解决办法

    在CentOS上安装node.js的时候报错:No acceptable C compiler found! 原因:没有c编译器. 解决办法:安装GCC 命令如下: #yum install gcc ...

  4. JS请求报错:Unexpected token T in JSON at position 0

    <?php /* 最近做一个ajax validate表单验证提交的代码,在ajax提交的时候 JS请求报错:Unexpected token T in JSON at position 0 描 ...

  5. webpack 打包压缩 ES6文件报错UglifyJs + Unexpected token punc ((); 或者 Unexpected token: operator (>)

    webpack 打包压缩 ES6文件报错UglifyJs + Unexpected token punc (();  或者 Unexpected token: operator (>) 解决方案 ...

  6. jsonp 请求报Uncaught SyntaxError: Unexpected token :

    $(document).ready(function() { jQuery.ajax({ type: 'GET', url: 'http://wncrunners.com/admin/colors.j ...

  7. 解决问题SyntaxError: Unexpected token import

    ES6语法的模块导入导出(import/export)功能,我们在使用它的时候,可能会报错: SyntaxError: Unexpected token import 语法错误:此处不应该出现impo ...

  8. ES6编译问题SyntaxError: Unexpected token import

    遇到SyntaxError: Unexpected token import 如何解决 ??? 究其原因是node es6问题这还不够,因为我们没有去配置babel,所以我们需要在.babelrc去做 ...

  9. MySQL 启动服务报错解决方案

    标签:ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid) 概述 文章 ...

随机推荐

  1. C++ 正则查找

    #include <iostream> #include <regex> using namespace std; int main() { string str; getli ...

  2. MVVM框架(Vue)

    问题: 一:说一下使用 JQuery和使用框架的区别? 二: 说一下对 MVVM的理解 三: Vue中如何实现响应式 四: vue中如何解析模板 五:vue整个实现流程 1. 说一下使用 JQuery ...

  3. XSS攻击(跨站攻击)

    漏洞描述 跨站脚本攻击(Cross-site scripting,简称XSS攻击),通常发生在客户端,可被用于进行隐私窃取.钓鱼欺骗.密码偷取.恶意代码传播等攻击行为.XSS攻击使用到的技术主要为HT ...

  4. Springboot项目启动报org.springframework.beans.factory.UnsatisfiedDependencyException

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hom ...

  5. const int* p

    若纠结于const int* p,int const* p,int* const p这三个指针,可以看视频 https://www.icourse163.org/learn/BUPT-10035640 ...

  6. Comet OJ - Contest #3 (A 比赛 加强版)二分答案

    考试的时候同届神犇 JZYshurak 出了一个  n=$10^5$ 的数据加强版. 刚开始没什么思路,但是忽然想到这个可以转成二分判定+暴力枚举的模型. 二分 ans, 使得大于等于 ans 的值小 ...

  7. set/unset

    自定义一个变量 name=value 查看现有变量 删除变量或函数 unset name

  8. bzoj 1924

    所用点的编号为输入顺序,因为只有在存在联通门的宫室中存在宝藏.其余点不考虑 对于每一行,选定一个横天门,向该行横天门连双向边,其余门单向边纵列同理自.由门用map判周围八个点是否存在,存在即连边 Ta ...

  9. SSH远程连接排错的过程

    SSH远程连接排错的过程 http://note.youdao.com/noteshare?id=bc81e9036cd2067cb1857ca9f54299a7 补充 ping命令用来测试主机之间网 ...

  10. qtableview 表格风格设置

    1.窗体无边框? tableView->setFrameShape(QFrame::NoFrame); 2.表格内容无边框? tableView->setShowGrid(false); ...