TimelordUK / node-sqlserver-v8

branched from node-sqlserver, SQL server driver compatible with all versions of Node
Other
138 stars 43 forks source link

The specified module could not be found. #161

Open rusandreev opened 4 years ago

rusandreev commented 4 years ago

The library works very well on the local machine, but I am getting an error trying to build on a TeamCity and deploy it to the server.

Node.js version - v12.16.2 (on local machine and server)

`Application has thrown an uncaught exception and is terminated: Error: Cannot open C:\TeamCity\BuildAgent_3\work\df0f347335528399\node_modules\msnodesqlv8\build\Release\sqlserverv8.node: Error: The specified module could not be found.

C:\TeamCity\BuildAgent_3\work\df0f347335528399\node_modules\msnodesqlv8\build\Release\sqlserverv8.node at Object. (C:\inetpub\Dev\Web\build\main-server.js:198891:216) at Object. (C:\inetpub\Dev\Web\build\main-server.js:198892:30) at webpack_require (C:\inetpub\Dev\Web\build\main-server.js:26:30) at C:\inetpub\Dev\Web\build\main-server.js:85601:21 at Object. (C:\inetpub\Dev\Web\build\main-server.js:86037:3) at webpack_require (C:\inetpub\Dev\Web\build\main-server.js:26:30) at Object. (C:\inetpub\Dev\Web\build\main-server.js:85528:12) at Object. (C:\inetpub\Dev\Web\build\main-server.js:85585:30) at __webpack_require__ (C:\inetpub\Dev\Web\build\main-server.js:26:30) at Object. (C:\inetpub\Dev\Web\build\main-server.js:198801:19)`

Any thoughts?

mtriff commented 4 years ago

That module should be downloaded during npm install. Are you running npm install during in your build script? If so, can you provide the output?

rusandreev commented 4 years ago

Yes, I am running Yarn install. Here is the output:


[12:40:34]Step 1/4: Yarn install (Command Line) (1m:14s)

[12:40:34][Step 1/4] Starting: C:\TeamCity\BuildAgent_3\temp\agentTmp\custom_script7178008537198531390.cmd

[12:40:34][Step 1/4] in directory: C:\TeamCity\BuildAgent_3\work\df0f347335528399

[12:40:35][Step 1/4] yarn install v1.7.0

[12:40:35][Step 1/4] warning package.json: No license field

[12:40:35][Step 1/4] warning app@2.13.0: No license field

[12:40:35][Step 1/4] [1/4] Resolving packages...

[12:40:36][Step 1/4] [2/4] Fetching packages...

[12:40:36][Step 1/4] (node:6432) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

[12:40:40][Step 1/4] info fsevents@1.2.13: The platform "win32" is incompatible with this module.

[12:40:40][Step 1/4] info "fsevents@1.2.13" is an optional dependency and failed compatibility 
check. Excluding it from installation.

[12:40:40][Step 1/4] [3/4] Linking dependencies...

[12:40:40][Step 1/4] warning " > extract-text-webpack-plugin@3.0.2" has incorrect peer dependency "webpack@^3.1.0".

[12:40:40][Step 1/4] warning " > postcss-cssnext@3.1.0" has unmet peer dependency "caniuse-lite@^1.0.30000697".

[12:40:40][Step 1/4] warning " > eslint-config-airbnb@18.1.0" has unmet peer dependency "eslint-plugin-react-hooks@^2.5.0 || ^1.7.0".

[12:41:40][Step 1/4] [4/4] Building fresh packages...

[12:41:49][Step 1/4] Done in 73.56s.

[12:41:49][Step 1/4] Process exited with code 0

[12:41:49]Step 2/4: Yarn Compiling (Node.js Yarn) (2m:20s)

[12:44:09]Step 3/4: Clean up (Command Line)

[12:44:09]Step 4/4: Copy to Prepare folder (Command Line)

[12:44:10]Publishing internal artifacts

[12:44:10]Build finished
TimelordUK commented 4 years ago

the library recently was moved to use prebuild see package.json

basically on each target machine you have to install the msnodeslv8 package as the executable is not provided in the npm package - rather it is fetched and placed into Release is your platform is supported else it will try and compile the code based on your specific version. Given you are using teamcity your server may not be permissioned to perform the fetch from git? you either need a step in team city to perform the install where prebuld fetches the correct version, or you need to build it locally on your box - or I guess if you know the version you are running you could manually place the binary into Release folder.


"install": "prebuild-install || node-gyp rebuild",

On Mon, 15 Jun 2020 at 17:50, Ruslan Andreev notifications@github.com wrote:

Yes, I am running Yarn install. Here is the output: [12:40:34]Step 1/4: Yarn install (Command Line) (1m:14s) [12:40:34][Step 1/4] Starting: C:\TeamCity\BuildAgent_3\temp\agentTmp\custom_script7178008537198531390.cmd [12:40:34][Step 1/4] in directory: C:\TeamCity\BuildAgent_3\work\df0f347335528399 [12:40:35][Step 1/4] yarn install v1.7.0 [12:40:35][Step 1/4] warning package.json: No license field [12:40:35][Step 1/4] warning avionero-app@2.13.0: No license field [12:40:35][Step 1/4] [1/4] Resolving packages... [12:40:36][Step 1/4] [2/4] Fetching packages... [12:40:36][Step 1/4] (node:6432) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. [12:40:40][Step 1/4] info fsevents@1.2.13: The platform "win32" is incompatible with this module. [12:40:40][Step 1/4] info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation. [12:40:40][Step 1/4] [3/4] Linking dependencies... [12:40:40][Step 1/4] warning " > extract-text-webpack-plugin@3.0.2" has incorrect peer dependency "webpack@^3.1.0". [12:40:40][Step 1/4] warning " > postcss-cssnext@3.1.0" has unmet peer dependency "caniuse-lite@^1.0.30000697". [12:40:40][Step 1/4] warning " > eslint-config-airbnb@18.1.0" has unmet peer dependency "eslint-plugin-react-hooks@^2.5.0 || ^1.7.0". [12:41:40][Step 1/4] [4/4] Building fresh packages... [12:41:49][Step 1/4] Done in 73.56s. [12:41:49][Step 1/4] Process exited with code 0 [12:41:49]Step 2/4: Yarn Compiling (Node.js Yarn) (2m:20s) [12:41:49][Step 2/4] Executing yarn via wrapping shell script [12:41:49][Step 2/4] Starting: cmd /c yarn iisnode [12:41:49][Step 2/4] in directory: C:\TeamCity\BuildAgent_3\work\df0f347335528399 [12:41:49][Step 2/4] yarn iisnode (2m:19s) [12:44:09][Step 2/4] Process exited with code 0 [12:44:09]Step 3/4: Clean up (Command Line) [12:44:09]Step 4/4: Copy to Prepare folder (Command Line) [12:44:10]Publishing internal artifacts [12:44:10]Build finished

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/TimelordUK/node-sqlserver-v8/issues/161#issuecomment-644249160, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXWJG3YEHNO3DNI6VRQETDRWZGNDANCNFSM4N6JU4IA .

rusandreev commented 4 years ago

I think fetching from git in TeamCity is ok since I have a bunch of npm packages and I didn't have a problem with installing them.

Could it be a problem with Yarn? Since I user yarn command to install npm packages.

TimelordUK commented 4 years ago

have you got administrator who can logon to the build server - find where the package has been installed and manually run install yourself and check the release folder to see if the binary has been populated. Then we firstly know your server at least can install and it is more how the components are being installed

On Tue, 16 Jun 2020 at 10:12, Ruslan Andreev notifications@github.com wrote:

I think fetching from git in TeamCity is ok since I have a bunch of npm packages and I didn't have a problem with installing them.

Could it be a problem with Yarn? Since I user yarn command to install npm packages.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/TimelordUK/node-sqlserver-v8/issues/161#issuecomment-644640238, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXWJGZ6W32XQB4DSAVMCD3RW4ZOFANCNFSM4N6JU4IA .

rusandreev commented 4 years ago

I can login to the build server now and checked the package: there is a sqlserverv8.node file in the proper place. But anyway I am getting an errorError: Cannot open C:\TeamCity\BuildAgent_4\work\df0f347335528399\node_modules\msnodesqlv8\build\Release\sqlserverv8.node: Error: The specified module could not be found.

DanMccloy commented 4 years ago

For me this was an issue with Webpack and how it was handling the sqlserverv8.node file with node-loader.

When building locally it would run fine - but node-loader/webpack was setting an absolute path to the module, meaning it would not run correctly when moved to another machine. The module itself was getting included in the bundle - but the path leading to it was wrong.

I changed my Webpack config up and included msnodesqlv8 as an external, then copied the msnodesqlv8 folder across separately using CopyPlugin.

rusandreev commented 4 years ago

@DanMccloy can you put here a Webpack config with CopyPlugin part? I'll really appreciate it

DanMccloy commented 4 years ago

This is what worked for me - this was my renderer config, as I'm using Electron. Just for reference I was also using version 0.6.0 of node-loader and 4.43.0 of webpack.


const CopyPlugin = require('copy-webpack-plugin');
const webpack = require('webpack')

module.exports = {
      resolve: {
        extensions: ['.js', '.jsx', '.json', '.css', '.ttf'],
      },
      externals: [{
        msnodesqlv8: './node_modules/msnodesqlv8',
      }],
      output: {
        libraryTarget: 'commonjs2',
      },
      module:{
        rules:[
          {
            test: /\.node$/,
            use: 'node-loader',
          },
          {
            test: /\.(m?js|node)$/,
            parser: { amd: false },
            use: {
              loader: '@marshallofsound/webpack-asset-relocator-loader',
              options: {
                outputAssetBase: 'native_modules',
              },
            },
          },
            {
                test: /\.(png|jp(e*)g|svg|gif)$/,  
                use: [{
                    loader: 'file-loader',
                    options: { 
                        name: '[name].[ext]',
                        outputPath: 'images/',
                    } 
                }]
            },
            {
                test:/\.css$/,
                use:['style-loader','css-loader']
            } , {
                test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
                use: [{
                    loader: 'file-loader',
                    options: {
                        name: '[name].[ext]',
                        outputPath: 'fonts/'
                    }
                }]
            } ,
            {
              test: /\.(html)$/,
              use: {
                loader: 'html-loader',
              }
            },
            {
              test: /\.worker.js$/,
              loader: 'worker-loader',
              options: { inline: true },
            },
            {
              test: /\.(js|jsx|ts|tsx)$/,
              exclude: /node_modules/,
              use: "babel-loader",
            }
       ]
    },
    plugins: [
        new CopyPlugin([
          { from: './node_modules/msnodesqlv8', to: './node_modules/msnodesqlv8' },
          { from: './node_modules/msnodesqlv8', to: './main/node_modules/msnodesqlv8' }
        ])
      ]
};
Almusamim commented 3 years ago

I'm having same problem with Quasar.. And can't figure out how to solve it!!!

node-loader: Error: The specified module could not be found.

image

rusandreev commented 3 years ago

Thanks, @DanMccloy. I changed the Webpack config and this error is gone. But now I am getting a connection error: code: 0 sqlstate: "IM002" And this error is appearing only on the dev machine. On the local machine everything is ok.

@DanMccloy can you say for what reason did you use this rule in config: { test: /\.(m?js|node)$/, parser: { amd: false }, use: { loader: '@marshallofsound/webpack-asset-relocator-loader', options: { outputAssetBase: 'native_modules', }, }, }, ?