启动服务报错如下:

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. Auth2.0 例子【转载】

    本文转载自:https://www.cnblogs.com/flashsun/p/7424071.html 1.引言 本篇文章是介绍OAuth2.0中最经典最常用的一种授权模式:授权码模式 非常简单的 ...

  2. Window脚本学习笔记之BAT简介

    本篇文章不是直接讲技术,而是对我自己学习这些年来的一番感触和简单的介绍,其间也穿插着一些基本的知识,若是学习技术者可跳过,亦不妨碍学习其他. BAT简介 BAT是Windows的批处理脚本,即以后缀“ ...

  3. Java&Selenium数据驱动【DataProvider+TestNG+Array】

    Java&Selenium数据驱动[DataProvider+TestNG+Array] package testNGWithDataDriven; import java.util.conc ...

  4. Python程序打包工具PyInstaller

    Python程序执行 py文件:直接提供源码,需要使用者自行安装Python并且安装依赖的各种库 pyc文件:pyc文件是Python解释器可以识别的二进制码,是跨平台的,需要使用者安装相应版本的Py ...

  5. DNS域名解析系统介绍

    域名系统(D N S)是一种用于T C P / I P应用程序的分布式数据库,它提供主机名字和 I P地址之间的转换及有关电子邮件的选路信息.这里提到的分布式是指在 I n t e r n e t上的 ...

  6. c#截图功能

    简化版: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Sys ...

  7. Boostnote跨平台 Markdown 编辑器

    Boostnote 0.11.6 发布了,Boostnote 是一个 Markdown 编辑器,可用于 Mac.Windows.Linux.Android 和 iOS 平台. 新版特性 Dev: 更新 ...

  8. 2、Spring Boot 2.x 快速入门

    1.2 Spring Boot 快速入门 1.2.1 开发环境和工具 JDK 1.8+:Spring Boot 2.x 要求 JDK 1.8 环境及以上版本.另外,Spring Boot 2.x 只兼 ...

  9. PyPI教程

    Wiki PyPI The Python Package Index, abbreviated as PyPI and also known as the Cheese Shop (a referen ...

  10. 003_STM32程序移植之_W25Q64

    1. 测试环境:STM32C8T6 2. 测试模块:W25Q64FLASH模块 3. 测试接口: 1. W25Q64FLASH模块接口: VCC3.3--------------------VCC3. ...