我在 index.js
之上import express from 'express'
import favicon from 'serve-favicon'
import router from express.Router()
我一直在
[nodemon] app crashed - waiting for file changes before starting...
[nodemon] restarting due to changes...
[nodemon] starting `babel-node ./index.js`
/Users/bheng/Desktop/express-app/node_modules/babel-core/lib/transformation/file/index.js:590
throw err;
^
SyntaxError: /Users/bheng/Desktop/express-app/index.js: Unexpected token (3:19)
1 | import express from 'express'
2 | import favicon from 'serve-favicon'
> 3 | import router from express.Router()
| ^
这是什么语法?我做错了什么 ?
答案 0 :(得分:3)
您已导入快递,因此要访问Router
您不再需要导入。
const router = express.Router();