I created a nextjs v13.5.3 project and installed node-oracledb 6.1.0. When I run the app I get the following error:
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Import trace for requested module:
./node_modules/oracledb/lib/oracledb.js
./node_modules/oracledb/index.js
./app/api/employees/route.js
⨯ node_modules\oracledb\lib\errors.js (588:9) @ getErr
⨯ Error: NJS-045: cannot load a node-oracledb Thick mode binary for Node.js. Please try using Thin mode.
Looked for F:\NextJS\HumanResources\human_resources\.next\server\build\Release\oracledb-6.1.0-win32-x64.node, F:\NextJS\HumanResources\human_resources\.next\server\build\Release\oracledb.node, F:\NextJS\HumanResources\human_resources\.next\server\build\Debug\oracledb.node, F:\NextJS\HumanResources\human_resources\.next\server\vendor-chunks\node_modules\oracledb\build\Release\oracledb-6.1.0-win32-x64.node, F:\NextJS\HumanResources\human_resources\.next\server\vendor-chunks\node_modules\oracledb\build\Release\oracledb.node
Node-oracledb installation instructions: https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html
at Object.throwErr (webpack-internal:///(rsc)/./node_modules/oracledb/lib/errors.js:451:11)
at _initCLib (webpack-internal:///(rsc)/./node_modules/oracledb/lib/oracledb.js:93:24)
at Object.initOracleClient (webpack-internal:///(rsc)/./node_modules/oracledb/lib/oracledb.js:524:30)
at eval (webpack-internal:///(rsc)/./app/api/employees/route.js:13:10)
at (rsc)/./app/api/employees/route.js (F:\NextJS\HumanResources\human_resources\.next\server\app\api\employees\route.js:238:1)
at __webpack_require__ (F:\NextJS\HumanResources\human_resources\.next\server\webpack-runtime.js:33:42)
at eval (webpack-internal:///(rsc)/./node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapi%2Femployees%2Froute&page=%2Fapi%2Femployees%2Froute&appPaths=&pagePath=private-next-app-dir%2Fapi%2Femployees%2Froute.js&appDir=F%3A%5CNextJS%5CHumanResources%5Chuman_resources%5Capp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=F%3A%5CNextJS%5CHumanResources%5Chuman_resources&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D!:16:124)
at (rsc)/./node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapi%2Femployees%2Froute&page=%2Fapi%2Femployees%2Froute&appPaths=&pagePath=private-next-app-dir%2Fapi%2Femployees%2Froute.js&appDir=F%3A%5CNextJS%5CHumanResources%5Chuman_resources%5Capp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=F%3A%5CNextJS%5CHumanResources%5Chuman_resources&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D! (F:\NextJS\HumanResources\human_resources\.next\server\app\api\employees\route.js:216:1)
at __webpack_require__ (F:\NextJS\HumanResources\human_resources\.next\server\webpack-runtime.js:33:42)
at __webpack_exec__ (F:\NextJS\HumanResources\human_resources\.next\server\app\api\employees\route.js:248:39)
at F:\NextJS\HumanResources\human_resources\.next\server\app\api\employees\route.js:249:108
at __webpack_require__.X (F:\NextJS\HumanResources\human_resources\.next\server\webpack-runtime.js:163:21)
at F:\NextJS\HumanResources\human_resources\.next\server\app\api\employees\route.js:249:47
at Object.<anonymous> (F:\NextJS\HumanResources\human_resources\.next\server\app\api\employees\route.js:252:3)
at Module._compile (node:internal/modules/cjs/loader:1241:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Module.require (node:internal/modules/cjs/loader:1115:19)
at mod.require (F:\NextJS\HumanResources\human_resources\node_modules\next\dist\server\require-hook.js:64:28)
at require (node:internal/modules/helpers:130:18)
at requirePage (F:\NextJS\HumanResources\human_resources\node_modules\next\dist\server\require.js:109:84)
at F:\NextJS\HumanResources\human_resources\node_modules\next\dist\server\load-components.js:59:84
at async loadComponentsImpl (F:\NextJS\HumanResources\human_resources\node_modules\next\dist\server\load-components.js:59:26)
at async DevServer.findPageComponentsImpl (F:\NextJS\HumanResources\human_resources\node_modules\next\dist\server\next-server.js:438:36) {
code: 'NJS-045',
page: '/api/employees'
}
null
⚠ ./node_modules/oracledb/lib/oracledb.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Import trace for requested module:
./node_modules/oracledb/lib/oracledb.js
./node_modules/oracledb/index.js
./app/api/employees/route.js
⚠ ./node_modules/oracledb/lib/oracledb.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Import trace for requested module:
./node_modules/oracledb/lib/oracledb.js
./node_modules/oracledb/index.js
./app/api/employees/route.js
⚠ ./node_modules/oracledb/lib/oracledb.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Import trace for requested module:
./node_modules/oracledb/lib/oracledb.js
./node_modules/oracledb/index.js
./app/api/employees/route.js
⚠ ./node_modules/oracledb/lib/oracledb.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Import trace for requested module:
./node_modules/oracledb/lib/oracledb.js
./node_modules/oracledb/index.js
./app/api/employees/route.js
⨯ node_modules\oracledb\lib\errors.js (588:9) @ getErr
⨯ Error: NJS-045: cannot load a node-oracledb Thick mode binary for Node.js. Please try using Thin mode.
Looked for F:\NextJS\HumanResources\human_resources\.next\server\build\Release\oracledb-6.1.0-win32-x64.node, F:\NextJS\HumanResources\human_resources\.next\server\build\Release\oracledb.node, F:\NextJS\HumanResources\human_resources\.next\server\build\Debug\oracledb.node, F:\NextJS\HumanResources\human_resources\.next\server\vendor-chunks\node_modules\oracledb\build\Release\oracledb-6.1.0-win32-x64.node, F:\NextJS\HumanResources\human_resources\.next\server\vendor-chunks\node_modules\oracledb\build\Release\oracledb.node
Node-oracledb installation instructions: https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html
at Object.throwErr (webpack-internal:///(rsc)/./node_modules/oracledb/lib/errors.js:451:11)
at _initCLib (webpack-internal:///(rsc)/./node_modules/oracledb/lib/oracledb.js:93:24)
at Object.initOracleClient (webpack-internal:///(rsc)/./node_modules/oracledb/lib/oracledb.js:524:30)
at eval (webpack-internal:///(rsc)/./app/api/employees/route.js:13:10)
at (rsc)/./app/api/employees/route.js (F:\NextJS\HumanResources\human_resources\.next\server\app\api\employees\route.js:238:1)
at __webpack_require__ (F:\NextJS\HumanResources\human_resources\.next\server\webpack-runtime.js:33:42)
at eval (webpack-internal:///(rsc)/./node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapi%2Femployees%2Froute&page=%2Fapi%2Femployees%2Froute&appPaths=&pagePath=private-next-app-dir%2Fapi%2Femployees%2Froute.js&appDir=F%3A%5CNextJS%5CHumanResources%5Chuman_resources%5Capp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=F%3A%5CNextJS%5CHumanResources%5Chuman_resources&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D!:16:124)
at (rsc)/./node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapi%2Femployees%2Froute&page=%2Fapi%2Femployees%2Froute&appPaths=&pagePath=private-next-app-dir%2Fapi%2Femployees%2Froute.js&appDir=F%3A%5CNextJS%5CHumanResources%5Chuman_resources%5Capp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=F%3A%5CNextJS%5CHumanResources%5Chuman_resources&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D! (F:\NextJS\HumanResources\human_resources\.next\server\app\api\employees\route.js:216:1)
at __webpack_require__ (F:\NextJS\HumanResources\human_resources\.next\server\webpack-runtime.js:33:42)
at __webpack_exec__ (F:\NextJS\HumanResources\human_resources\.next\server\app\api\employees\route.js:248:39)
at F:\NextJS\HumanResources\human_resources\.next\server\app\api\employees\route.js:249:108
at __webpack_require__.X (F:\NextJS\HumanResources\human_resources\.next\server\webpack-runtime.js:163:21)
at F:\NextJS\HumanResources\human_resources\.next\server\app\api\employees\route.js:249:47
at Object.<anonymous> (F:\NextJS\HumanResources\human_resources\.next\server\app\api\employees\route.js:252:3)
at Module._compile (node:internal/modules/cjs/loader:1241:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Module.require (node:internal/modules/cjs/loader:1115:19)
at mod.require (F:\NextJS\HumanResources\human_resources\node_modules\next\dist\server\require-hook.js:64:28)
at require (node:internal/modules/helpers:130:18)
at requirePage (F:\NextJS\HumanResources\human_resources\node_modules\next\dist\server\require.js:109:84)
at F:\NextJS\HumanResources\human_resources\node_modules\next\dist\server\load-components.js:59:84
at async loadComponentsImpl (F:\NextJS\HumanResources\human_resources\node_modules\next\dist\server\load-components.js:59:26)
at async DevServer.findPageComponentsImpl (F:\NextJS\HumanResources\human_resources\node_modules\next\dist\server\next-server.js:438:36) {
code: 'NJS-045',
page: '/api/employees'
}
null
○ Compiling /_error ...
I installed Oracle instant client_21_7 that supports my oracle database 11g and the following are snippets of my code: ./app/test/route.js:
const oracledb = require('oracledb');
oracledb.initOracleClient({ libDir: 'C:\\Oracle\\instantclient_12_1' });
-package.json:
{
"name": "human_resources",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "webpack --config webpack.config.js",
"start": "next start",
"lint": "next lint",
"startNow": "webpack --config webpack.config.js"
},
"dependencies": {
"next": "latest",
"oracledb": "^6.1.0",
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"autoprefixer": "latest",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"postcss": "latest",
"tailwindcss": "latest",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4"
},
"resolutions": {
"react-countup/countup.js": "2.5.0"
}
}
-webpack.config.js:
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const config = {
entry: './index.js',
target: 'node',
output: {
path: path.join(__dirname, 'dist'),
filename: 'myapp.js',
},
mode: 'production',
watch: false,
plugins: [
new CleanWebpackPlugin(),
new CopyPlugin({
patterns: [{
// Copy Thick-mode Oracle Database driver binaries to dist
from: path.resolve(__dirname, 'node_modules/oracledb/build'),
to: 'node_modules/oracledb/build',
}],
})
],
};
module.exports = config;
I still get the same Erorr.
I had a similar issue with nextjs version > 13, I was able to resolve it by adding the following to my
next.config.jsCurrently using versions:
Please note - If you are using thin mode and any version higher than [email protected], you will need
sec_case_sensitive_logonto betruepassword_versionsto not include10Gmentioned here https://github.com/oracle/node-oracledb/issues/1584#issuecomment-1702511642
You should be fine in thick mode
Hope this helps!