Node.js启动服务报错SyntaxError: Unexpected token import
启动服务报错如下:
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的更多相关文章
- 『奇葩问题集锦』function * (next){ 执行报错 SyntaxError: Unexpected token *
这是因为 app.use(function * (){ 语句中有一个 * ,这种方式被称为generator functions ,一般写作function *(){...} 的形式,在此类func ...
- js报Uncaught SyntaxError: Unexpected token <错误 解决方法
js报Uncaught SyntaxError: Unexpected token <错误 解决方法 错因 js被shiro的拦截器拦下,访问不了 #shiro的配置 shiro: hash-a ...
- 在CentOS上安装node.js的时候报错:No acceptable C compiler found!解决办法
在CentOS上安装node.js的时候报错:No acceptable C compiler found! 原因:没有c编译器. 解决办法:安装GCC 命令如下: #yum install gcc ...
- JS请求报错:Unexpected token T in JSON at position 0
<?php /* 最近做一个ajax validate表单验证提交的代码,在ajax提交的时候 JS请求报错:Unexpected token T in JSON at position 0 描 ...
- webpack 打包压缩 ES6文件报错UglifyJs + Unexpected token punc ((); 或者 Unexpected token: operator (>)
webpack 打包压缩 ES6文件报错UglifyJs + Unexpected token punc ((); 或者 Unexpected token: operator (>) 解决方案 ...
- jsonp 请求报Uncaught SyntaxError: Unexpected token :
$(document).ready(function() { jQuery.ajax({ type: 'GET', url: 'http://wncrunners.com/admin/colors.j ...
- 解决问题SyntaxError: Unexpected token import
ES6语法的模块导入导出(import/export)功能,我们在使用它的时候,可能会报错: SyntaxError: Unexpected token import 语法错误:此处不应该出现impo ...
- ES6编译问题SyntaxError: Unexpected token import
遇到SyntaxError: Unexpected token import 如何解决 ??? 究其原因是node es6问题这还不够,因为我们没有去配置babel,所以我们需要在.babelrc去做 ...
- MySQL 启动服务报错解决方案
标签:ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid) 概述 文章 ...
随机推荐
- Maven 发布项目到Jetty服务器———5
官网: http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html 1.安装配置插件 2. 运行 命令: je ...
- Java&Selenium智能等待方法封装
Java&Selenium智能等待方法封装 ExpectedConditions方法还有很多,自然也可以继续扩展很多 package util; import org.openqa.selen ...
- charles设置截图及常见问题汇总
常见问题: 1.手机配置charles代理后,手机无法上网,无法访问chls.pro/ssl,解决办法:关闭电脑防火墙: 关闭后即可上网. 2.设置代理请求,charles看不到任何请求,解决办法:p ...
- Nginx中ngx_http_upstream_module模块
用于将多个服务器器定义成服务器器组,⽽而由 proxy_pass , fastcgi_pass 等指令进⾏行行引⽤用upstream backend {server backend1.example. ...
- LevelDB的源码阅读(一)
源码下载 git clone https://github.com/google/leveldb.git 项目结构 db/, 数据库逻辑 doc/, MD文档 helpers/, LevelDB内存版 ...
- mysql对两个字段进行自定义排序
Mysql order by 多字段排序 ') desc,ADD_DATE desc mysql单个字段降序排序: select * from table order by id desc; mysq ...
- 父元素设置固定宽度并设置overflow:scroll,如何让子元素撑开父元素
<div class="a"> <div class="b"> <div class="c">内容内容, ...
- [Javascript] Create an Image with JavaScript Using Fetch and URL.createObjectURL
Most developers are familiar with using img tags and assigning the src inside of HTML. It is also po ...
- ueditor+复制word图片粘贴上传
Chrome+IE默认支持粘贴剪切板中的图片,但是我要发布的文章存在word里面,图片多达数十张,我总不能一张一张复制吧?Chrome高版本提供了可以将单张图片转换在BASE64字符串的功能.但是无法 ...
- [Luogu] 借教室
https://www.luogu.org/problemnew/show/P1083 二分第i天不满足 前缀和 + 差分判断 #include <iostream> #include & ...