Open VittorioMorellini opened 8 months ago
https://github.com/TimelordUK/node-sqlserver-v8/issues/294
is it simiar to this
https://github.com/eisberg-labs/nextjs-node-loader
does this help at all
https://github.com/eisberg-labs/nextjs-node-loader
does this help at all
Hi thank you, I install the package and add to my next.config this:
const nextConfig = { experimental: { serverActions: true }, reactStrictMode: true, images: { remotePatterns: [ { protocol: 'https', hostname: 'raw.githubusercontent.com', port: '', pathname: '/VittorioMorellini/articles/main/images/**', }, ], }, webpack: (config, { dev, isServer, webpack, nextRuntime }) => { config.module.rules.push({ test: /.node$/, use: [ { loader: "nextjs-node-loader", // options: { // flags: os.constants.dlopen.RTLD_NOW, // outputPath: config.output.path // } }, ], }); return config; }, } module.exports = nextConfig
But I did not solve, do I have to install webpack? I did not add it, I did not use it I am not able to solve yet
for now can you try this
yarn add nextjs-node-loader --save-dev
edit node_modules/msnodesqlv8/lib/util.js and add .node on end
const utilModule = ((() => {
const { QueryAggregator } = require('./query-aggregator')
const { SchemaSplitter } = require('./shema-splitter')
const cppDriver = require('../build/Release/sqlserverv8.node')
/** @type {import('next').NextConfig} */
module.exports = {
experimental: {
serverActions: true
},
reactStrictMode: true,
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'raw.githubusercontent.com',
port: '',
pathname: '/VittorioMorellini/articles/main/images/**',
},
],
},
webpack: (config, options) => {
// console.log('HERE WE ARE')
config.module.rules.push({
test: /\.node$/,
use: [
{
loader: "nextjs-node-loader",
options: {
outputPath: config.output.path
}
},
],
})
return config
}
}
yarn run v1.22.21
$ next dev
▲ Next.js 13.5.6
- Local: http://localhost:3000
- Environments: .env.development
- Experiments (use at your own risk):
· serverActions
✓ Ready in 2.5s
○ Compiling /page ...
✓ Compiled /page in 4.1s (1511 modules)
[next-auth][warn][NEXTAUTH_URL]
https://next-auth.js.org/warnings#nextauth_url
[next-auth][warn][NO_SECRET]
https://next-auth.js.org/warnings#no_secret
{ session: null }
✓ Compiled in 1920ms (603 modules)
{ session: null }
✓ Compiled /api/auth/[...nextauth]/route in 200ms (913 modules)
[next-auth][warn][NEXTAUTH_URL]
https://next-auth.js.org/warnings#nextauth_url
[next-auth][warn][NO_SECRET]
https://next-auth.js.org/warnings#no_secret
Who am I?
I am a software engineer and I love web development.
I am not so young, unfortunately, I am a full stack developer because I don't want to leave nor backend neither frontend
I have worked as a software engineer for more than twenty years in product and consultancy companies.
I have the determination to be a reference as a Senior SDE on the Web
It worked with your suggestion, Thank you for your suggestion. But if I have to edit the util.js it is not so smooth, it is not an optimized configuration.
Do I need webpack installed and a package? I think yes Do you install webpack? I did it but maube it is not necessary
Thank you for your support
yes i will have to release a patch to msnodesqlv8 but first i need to check it still works on linux and windows without nextjs this can allow you to test for time being
Thank you, now I can continue to work. What I did not understand is that I did not get this error on my project in production with next 13.4.12 or 13.5.6 using this driver.
I had in my portfolio with app dir, it is very starnge. I did not get. Thank you for your support, it is wonderfull
You are incredible, support magic. I used msnodesqlv8 in production with next.js 13.4.12 and 13.5.6 and I did not get the problem
With this next I started with next14 and I did not solve, it is strange. Even when I downgrade next.js I did not solve Thank you for your suggestion
Hi msnodesqlv8, with the new release of msnodesqlv8 4.1.2 I solved the compilation problem. But I have a problem in runtime when a Open a page (every time the page change: detail of post, contacts with noquery). This error happens in random pages, after a little navigation:
Unhandled Runtime Error
Error: nextjs-node-loader:
Error: Unable to initialize msnodesql
Call Stack
eval
node_modules\msnodesqlv8\build\Release\sqlserverv8.node (5:0)
(rsc)/./node_modules/msnodesqlv8/build/Release/sqlserverv8.node
file:///C:/PersonalProjects/Next/portfolio14.0/.next/server/vendor-chunks/msnodesqlv8.js (651:1)
__webpack_require__
file:///C:/PersonalProjects/Next/portfolio14.0/.next/server/webpack-runtime.js (33:43)
require
node_modules\msnodesqlv8\lib\util.js (4:20)
eval
node_modules\msnodesqlv8\lib\util.js (34:0)
(rsc)/./node_modules/msnodesqlv8/lib/util.js
file:///C:/PersonalProjects/Next/portfolio14.0/.next/server/vendor-chunks/msnodesqlv8.js (631:1)
__webpack_require__
file:///C:/PersonalProjects/Next/portfolio14.0/.next/server/webpack-runtime.js (33:43)
require
node_modules\msnodesqlv8\lib\table-column.js (4:19)
There is still something wrong, I did not realize what I am missing. Do I miss webpack? do I miss gyp package? What do I miss?
https://github.com/TimelordUK/todo-with-nextjs_msnodesqlv8
can you try this very simple application - i changed a demo to simply use msnodesqlv8 it works without any of the above at all
if this works maybe can you use the same design,
I am sorry I do not have the time to dig into your specific application
see dbConnect.js
and the index.js, [id].js for usage
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
event - compiled client and server successfully in 203 ms (125 modules)
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
wait - compiling / (client and server)...
event - compiled client and server successfully in 74 ms (163 modules)
wait - compiling /api/task...
event - compiled client and server successfully in 62 ms (174 modules)
[index] opening connection
select * from Task
[ { id: 3, completed: 0, task: 'new task update', _id: 3 } ]
[index] closing connection
https://github.com/VittorioMorellini/portfolio14
This is my repo with msnodesqlv8 (4.1.1) and next 13.5.6 I am using node 18.18.2
I have this error in build, I am not able to understand, I used already this driver with Next.js 13 and I did not get errors. Why is this error happening? There is no reason to happen. The installation is going good, but the build is not working. I have tried everything, delete node_modules and reinstall. But the error still appears I had prisma in this project before and I removed. This package for sql server does not compile
Vittorio Morellini