ibm-messaging / mq-mqi-nodejs

Calling IBM MQ from Node.js - a JavaScript MQI wrapper
Apache License 2.0
79 stars 42 forks source link

Exception "require is not defined" in webpack:///./node_modules/node-gyp-build/index.js #104

Closed somowhere closed 3 years ago

somowhere commented 3 years ago

here is my package.json: "dependencies": { "axios": "0.18.1", "core-js": "3.6.5", "element-ui": "2.13.2", "ibmmq": "^0.9.15", "js-cookie": "2.2.0", "normalize.css": "7.0.0", "nprogress": "0.2.0", "path-to-regexp": "2.4.0", "vue": "2.6.10", "vue-router": "3.0.6", "vuex": "3.1.0" }, "devDependencies": { "@vue/cli-plugin-babel": "4.4.4", "@vue/cli-plugin-eslint": "4.4.4", "@vue/cli-plugin-unit-jest": "4.4.4", "@vue/cli-service": "4.4.4", "@vue/test-utils": "1.0.0-beta.29", "autoprefixer": "9.5.1", "babel-eslint": "10.1.0", "babel-jest": "23.6.0", "babel-plugin-dynamic-import-node": "2.3.3", "chalk": "2.4.2", "connect": "3.6.6", "eslint": "6.7.2", "eslint-plugin-vue": "6.2.2", "html-webpack-plugin": "3.2.0", "mockjs": "1.0.1-beta3", "runjs": "4.3.2", "sass": "1.26.8", "sass-loader": "8.0.2", "script-ext-html-webpack-plugin": "2.1.3", "serve-static": "1.13.2", "svg-sprite-loader": "4.1.3", "svgo": "1.2.2", "vue-template-compiler": "2.6.10" }, when I import module,I got a image here is my code: image

somowhere commented 3 years ago

image

ibmmqmet commented 3 years ago

It looks like webpack doesn't like using variables in require statements: See here for example. Since the only place that is done in the current package is for loading the platform-specifc variations of the mqidefs file, I can probably change to hardcoded strings instead of building it up dynamically. But since I don't use webpack, I don't know if that's sufficient. You could probably test it by directly editing the mqidefs.js file under the node_modules directory and changing the variable loading to a fixed string based on your platform.

ibmmqmet commented 3 years ago

mqidefs.js was changed in v0.9.16 to deal with this