You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+30
Original file line number
Diff line number
Diff line change
@@ -116,3 +116,33 @@ try {
116
116
// error handling
117
117
}
118
118
```
119
+
120
+
## Usage as ESM module
121
+
122
+
If you are launching your Node application with `--experimental-modules`, `knex.mjs` should be picked up automatically and named ESM import should work out-of-the-box.
123
+
Otherwise, if you want to use named imports, you'll have to import knex like this:
124
+
```js
125
+
import { knex } from'knex/knex.mjs'
126
+
```
127
+
128
+
You can also just do the default import:
129
+
```js
130
+
importknexfrom'knex'
131
+
```
132
+
133
+
If you are not using TypeScript and would like the IntelliSense of your IDE to work correctly, it is recommended to set the type explicitly:
0 commit comments