我们正在将React集成到我们现有的Web应用程序中,并在使用Jenkins构建服务器构建React组件时遇到问题。
我所做的步骤
var ExtractTextPlugin = require('extract-text-webpack-plugin'); // for extracting generated CSS to external file(s)
const path = require('path');
const nodeModulesPath = '/usr/local/lib/node_modules/';
module.exports = (env, argv) => ({
resolveLoader: {
modules: (argv.mode === 'production' ? [nodeModulesPath] : ['./node_modules/'])
},
启动Jenkins时,出现以下错误
[echo] NPM NODE PATH Set completed
[exec] /usr/local/lib
[exec] ├── npm@5.6.0
[exec] ├── webpack@4.16.5
[exec] └── webpack-cli@2.1.5
[exec]
[echo] NPM run deploy starts /apps/jenkins_slave/tools/web/extensions/custom/
[echo]
[exec]
[exec] > markethub-plus-ui@1.0.0 deploy /apps/jenkins_slave/tools/web/extensions/custom/
[exec] > webpack --mode production --display-error-details
[exec]
[exec] /usr/local/lib/node_modules/webpack-cli/bin/webpack.js:243
[exec] throw err;
[exec] ^
[exec]
[exec] Error: Cannot find module 'extract-text-webpack-plugin'
[exec] at Function.Module._resolveFilename (module.js:547:15)
[exec] at Function.Module._load (module.js:474:25)
[exec] at Module.require (module.js:596:17)
[exec] at require (/usr/local/lib/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
[exec] at Object.<anonymous> (/apps/jenkins_slave/tools/web/extensions/custom/webpack.config.js:1:87)
当我直接登录Jenkins构建服务器并从bash运行时,此方法有效。仅当我通过Jenkins用户控制台启动构建时,才出现上述错误。
以前有人尝试过吗?还是在这种情况下集成React的正确方法是什么?请让我知道您的想法。
干杯。