how ES7 import module's object in Node.js

299 views Asked by At
var GoogleStrategy = require('passport-google-oauth20').Strategy;

How can I use ES2017's way to write it? I try

import GoogleStrategy from ('passport-google-oauth20').Strategy

But it couldn't work

How can I use ES7 to write it? Thanks

here is the package.json file, It set the type as module. So I couldn't use const...=require('...')

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "start": "nodemon index.js"
  },
1

There are 1 answers

1
Eric Fortis On
import { Strategy } from 'passport-google-oauth20';