启动服务报错如下:

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. javascript中如何判断数组是数组

    if (!Array.isArray) { Array.isArray = function(arg) { return Object.prototype.toString.call(arg) === ...

  2. string的 insert

    // inserting into a string #include <iostream> #include <string> int main () { std::stri ...

  3. Java&Selenium自动化测试调用JS实现单击

    Java&Selenium自动化测试调用JS实现单击 /* * the method of invoking js to do something * * @author davieyang ...

  4. Web应用中的缓存一致性问题

    上篇总结了缓存中出现频率比较高的一些问题,今天详细说说web应用中的缓存一致性问题. 主要说以下三个方面 数据库与缓存中数据不一致出现的情形 发生不一致时的优化思路 如何保证数据库与缓存的一致性 先来 ...

  5. setuptools 版本太旧

    第二是 setuptools 版本太旧,所以出现以下问题Command "python setup.py egg_info" failed with error code 1 in ...

  6. Python+request+ smtplib 测试结果html报告邮件发送(上)《五》

    此方法通用适合所有邮箱的使用,只需注意几个点,如下: QQ邮箱.其他非QQ邮箱的写法,区别点如下: #--------------------------使用腾讯企业邮箱作为发件人的操作如下----- ...

  7. C# DocumentCompleted事件多次条用解决方案

    private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { ...

  8. Django 数据库mysql到models的映射方法

    Django自动生成models 如果数据库表已经存在,执行命令,可以自动生成Models模型,实现models与数据表的映射 >>> python manage.py inspec ...

  9. mouseover([[data],fn])

    mouseover([[data],fn]) 概述 当鼠标指针位于元素上方时,会发生 mouseover 事件. 该事件大多数时候会与 mouseout 事件一起使用.直线电机选型 注释:与 mous ...

  10. PHP mysqli_connect_error() 函数

    返回上一次连接错误的错误描述: <?php $con=mysqli_connect("localhost","wrong_user","my_p ...