使用AppDynamics库时,有人遇到过Webpack依赖项编译问题吗?您找到了解决该问题的方法吗?我相信这是源于其库的问题。
当尝试安装AppDynamics软件包以监视Node.js / Express应用程序时,我们的Webpack构建过程无法导入少数依赖项。具体来说,错误输出为:
Running with gitlab-runner 11.8.0 (4745a6f3)
on docker-auto-scale 72989761
Using Docker executor with image postgres ...
Starting service postgres:latest ...
Pulling docker image postgres:latest ...
Using docker image sha256:30bf4f039abe0affe9fe4f07a13b00ea959299510626d650c719fb10c4f41470 for postgres:latest ...
Waiting for services to be up and running...
Pulling docker image postgres ...
Using docker image sha256:30bf4f039abe0affe9fe4f07a13b00ea959299510626d650c719fb10c4f41470 for postgres ...
Running on runner-72989761-project-7829066-concurrent-0 via runner-72989761-srm-1551974294-08e28deb...
Cloning repository...
Cloning into '/builds/kimtang/SpringBootTimeWithSwagger'...
Checking out 1399a232 as master...
Skipping Git submodules setup
$ export PGPASSWORD=$POSTGRES_PASSWORD
$ psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 'OK' AS status;"
status
--------
OK
(1 row)
$ psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SHOW config_file;"
config_file
------------------------------------------
/var/lib/postgresql/data/postgresql.conf
(1 row)
$ cd /var/lib/postgresql/data
$ dir
$ ls -a
.
..
$ cat postgresql.conf
cat: postgresql.conf: No such file or directory
ERROR: Job failed: exit code 1
我们的项目设置为: -Webpack v4.29.0 -Node.js v11.0.0 -Appdynamics v4.5
Appdynamics用法位于我们服务器文件的顶部,为:
WARNING in ./node_modules/appdynamics/lib/core/agent.js 445:8-28
require.main.require is not supported by webpack.
@ ./node_modules/appdynamics/index.js 1:17-44
@ ./server.ts
ERROR in ./node_modules/appdynamics-zmq/lib/index.js
Module not found: Error: Can't resolve '../zmq' in '.../my-app/node_modules/appdynamics-zmq/lib'
@ ./node_modules/appdynamics-zmq/lib/index.js 24:10-27
@ ./node_modules/appdynamics-zmq/index.js
@ ./node_modules/appdynamics/lib/libproxy/proxy-transport.js
@ ./node_modules/appdynamics/lib/libproxy/libproxy.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts
ERROR in ./node_modules/appdynamics-libagent/index.js
Module not found: Error: Can't resolve './appd_libagent' in '.../my-app/node_modules/appdynamics-libagent'
@ ./node_modules/appdynamics-libagent/index.js 36:9-35
@ ./node_modules/appdynamics/lib/libagent/libagent-connector.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts
ERROR in ./node_modules/appdynamics-native/index.js
Module not found: Error: Can't resolve './appdynamics' in '.../my-app/node_modules/appdynamics-native'
@ ./node_modules/appdynamics-native/index.js 29:10-34
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts
ERROR in ./node_modules/appdynamics-protobuf/index.js
Module not found: Error: Can't resolve './protobuf_for_node' in '.../my-app/node_modules/appdynamics-protobuf'
@ ./node_modules/appdynamics-protobuf/index.js 29:10-40
@ ./node_modules/appdynamics/lib/libproxy/proxy-transport.js
@ ./node_modules/appdynamics/lib/libproxy/libproxy.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts
ERROR in ./node_modules/log4js/lib/appenders/hipchat.js
Module not found: Error: Can't resolve 'hipchat-notifier' in '.../my-app/node_modules/log4js/lib/appenders'
@ ./node_modules/log4js/lib/appenders/hipchat.js 3:14-41
@ ./node_modules/log4js/lib/appenders sync ^\.\/.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/appdynamics/lib/core/logger.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts
ERROR in ./node_modules/log4js/lib/appenders/loggly.js
Module not found: Error: Can't resolve 'loggly' in '.../node_modules/log4js/lib/appenders'
@ ./node_modules/log4js/lib/appenders/loggly.js 3:11-28
@ ./node_modules/log4js/lib/appenders sync ^\.\/.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/appdynamics/lib/core/logger.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts
ERROR in ./node_modules/log4js/lib/appenders/mailgun.js
Module not found: Error: Can't resolve 'mailgun-js' in '.../my-app/node_modules/log4js/lib/appenders'
@ ./node_modules/log4js/lib/appenders/mailgun.js 34:14-35
@ ./node_modules/log4js/lib/appenders sync ^\.\/.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/appdynamics/lib/core/logger.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts
ERROR in ./node_modules/log4js/lib/appenders/smtp.js
Module not found: Error: Can't resolve 'nodemailer' in '.../my-app/node_modules/log4js/lib/appenders'
@ ./node_modules/log4js/lib/appenders/smtp.js 4:13-34
@ ./node_modules/log4js/lib/appenders sync ^\.\/.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/appdynamics/lib/core/logger.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts
ERROR in ./node_modules/log4js/lib/appenders/slack.js
Module not found: Error: Can't resolve 'slack-node' in '.../node_modules/log4js/lib/appenders'
@ ./node_modules/log4js/lib/appenders/slack.js 2:12-33
@ ./node_modules/log4js/lib/appenders sync ^\.\/.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/appdynamics/lib/core/logger.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts
我们的Webpack配置为:
// AppDynamics monitoring
require("appdynamics").profile({
controllerHostName: ***
controllerPort: 443,
controllerSslEnabled: true,
accountName: ****
accountAccessKey: ***
applicationName: ***
tierName: ***
nodeName: '01'
});
到目前为止,我们已经尝试将Webpack版本降级,将Node环境降级到10.15,并对AppDynamics包使用其他导入方法,但这似乎是Appdynamics库内部的问题? 主要问题是,使用Appdynamics库时,是否有人遇到过Webpack依赖项编译问题?您找到了解决该问题的方法吗?
任何帮助或线索都会受到赞赏❤️
答案 0 :(得分:0)
解决方案是在Webpack配置中将“ appdynamics”添加到“外部”:https://webpack.js.org/configuration/externals/
这允许AppDynamics使用默认的Node.js需要导入。