Skip to content

Comments

Fix mysql2 plugin install error#74

Merged
kezhenxu94 merged 1 commit intoapache:masterfrom
Jiannan-dev:fix_mysql2_error
Mar 10, 2022
Merged

Fix mysql2 plugin install error#74
kezhenxu94 merged 1 commit intoapache:masterfrom
Jiannan-dev:fix_mysql2_error

Conversation

@Jiannan-dev
Copy link

@Jiannan-dev Jiannan-dev commented Mar 10, 2022

I've added an optional method to get the version information of the plugin. For most plugins it's not necessary to implement this method, the default require('lib/package.json') method can get its version, but the few libraries that specify export in package.json can't use default method. They must implement their own getVersion() method to get the version

Fix apache/skywalking#7879

@wu-sheng wu-sheng added this to the 0.4.0 milestone Mar 10, 2022
@wu-sheng wu-sheng added the bug Something isn't working label Mar 10, 2022
@Jiannan-dev
Copy link
Author

Also, for require('mysql/lib/connect') change to require('mysql').Connection also because of the restriction of the export field,The meaning of the export field can be viewed here:https://nodejs.org/dist/latest-v16.x/docs/api/packages.html
image

The export field of mysql2 is as follows:

"exports": {
    ".": "./index.js",
    "./promise": "./promise.js",
    "./promise.js": "./promise.js"
  }

This also means that except for require('mysql2'), require('mysql2/promise') and require('mysql2/promise.js'), all other requires are illegal, such as require('mysql2/lib/connection' ) and require('mysql2/package.json')

@Jiannan-dev
Copy link
Author

@wu-sheng
Could help to do this pr associated to Issue:apache/skywalking#7879 ,thanks

@wu-sheng
Copy link
Member

image

This should work.

Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ruleeeer

@kezhenxu94 kezhenxu94 merged commit 466543d into apache:master Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Nodejs][Bug] Getting error log "Error installing plugin mysql2 *" when start agent

3 participants