LiveWithPassion LiveWithPassion - 2 years ago 105
Node.js Question

How to rewrite this require module with import module syntax

I'm new to JavaScript and trying to import this module using ES6. It's currently written as:

var neo4j = require('neo4j-driver').v1;

I have:

import neo4j from 'neo4j-driver;'

But I have no idea how to handle the .v1?


Thank you.

Answer Source

Since v1 is a member of the module, you can use import's member syntaxes.

Including { member as alias }:

import { v1 as neo4j } from 'neo4j-driver';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download