webpack-cli无法加载webpack.config.js

p1tboqfb  于 2022-11-30  发布在  Webpack
关注(0)|答案(1)|浏览(472)

我尝试将sylius项目的主题更改为bootstraptheme,我正在使用本教程https://docs.sylius.com/en/1.9/book/themes/bootstrap-theme.html来完成此操作,但我遇到了一个错误,缺少一些东西,无法工作。我在Ubuntu 18.4系统中尝试过以下命令:

yarn encore dev    
yarn encore production    
yarn encore dev-server

这是the result

yarn run v1.22.5
$ /home/safa/git_environment/MyFirstShop/node_modules/.bin/encore production
Running webpack ...

 WARNING  Webpack Encore requires version ^9.0.1 || ^10.0.0 || ^11.0.0 of sass-loader, but your version (7.3.1) is too old. The related feature will probably *not* work correctly.
 WARNING  Webpack Encore requires version ^9.0.1 || ^10.0.0 || ^11.0.0 of sass-loader, but your version (7.3.1) is too old. The related feature will probably *not* work correctly.
 WARNING  Webpack Encore requires version ^9.0.1 || ^10.0.0 || ^11.0.0 of sass-loader, but your version (7.3.1) is too old. The related feature will probably *not* work correctly.
 WARNING  Webpack Encore requires version ^9.0.1 || ^10.0.0 || ^11.0.0 of sass-loader, but your version (7.3.1) is too old. The related feature will probably *not* work correctly.
[webpack-cli] Failed to load '/home/safa/git_environment/MyFirstShop/webpack.config.js' config
[webpack-cli] ReferenceError: bootstrapTheme is not defined
    at Object.<anonymous> (/home/safa/git_environment/MyFirstShop/webpack.config.js:52:1)
    at Module._compile (/home/safa/git_environment/MyFirstShop/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (/home/safa/git_environment/MyFirstShop/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at loadConfig (/home/safa/git_environment/MyFirstShop/node_modules/webpack-cli/lib/webpack-cli.js:1327:31)
    at WebpackCLI.resolveConfig (/home/safa/git_environment/MyFirstShop/node_modules/webpack-cli/lib/webpack-cli.js:1459:44)
    at WebpackCLI.createCompiler (/home/safa/git_environment/MyFirstShop/node_modules/webpack-cli/lib/webpack-cli.js:1837:33)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

webpack.config.js:

const path = require('path');
const Encore = require('@symfony/webpack-encore');

const syliusBundles = path.resolve(__dirname, 'vendor/sylius/sylius/src/Sylius/Bundle/');
const uiBundleScripts = path.resolve(syliusBundles, 'UiBundle/Resources/private/js/');
const uiBundleResources = path.resolve(syliusBundles, 'UiBundle/Resources/private/');

// Shop config
Encore
  .setOutputPath('public/build/shop/')
  .setPublicPath('/build/shop')
  .addEntry('shop-entry', './assets/shop/entry.js')
  .disableSingleRuntimeChunk()
  .cleanupOutputBeforeBuild()
  .enableSourceMaps(!Encore.isProduction())
  .enableVersioning(Encore.isProduction())
  .enableSassLoader();

const shopConfig = Encore.getWebpackConfig();

shopConfig.resolve.alias['sylius/ui'] = uiBundleScripts;
shopConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources;
shopConfig.resolve.alias['sylius/bundle'] = syliusBundles;
shopConfig.name = 'shop';

Encore.reset();
Encore
  .setOutputPath('public/bootstrap-theme')
  .setPublicPath('/bootstrap-theme')
  .addEntry('app', './themes/BootstrapChildTheme/assets/entry.js')
  .disableSingleRuntimeChunk()
  .cleanupOutputBeforeBuild()
  .enableSassLoader()
  .enableSourceMaps(!Encore.isProduction())
  .enableVersioning(Encore.isProduction());

const bootstrapThemeConfig = Encore.getWebpackConfig();
bootstrapThemeConfig.name = 'bootstrapTheme';

bootstrapTheme.resolve.alias['sylius/ui'] = uiBundleScripts;
bootstrapTheme.resolve.alias['sylius/ui-resources'] = uiBundleResources;
bootstrapTheme.resolve.alias['sylius/bundle'] = syliusBundles;
bootstrapTheme.externals = Object.assign({}, bootstrapTheme.externals, { window: 'window', document: 'document' });
bootstrapTheme.name = 'admin';

module.exports = [shopConfig, bootstrapTheme];

package.json:

{
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.35",
    "@fortawesome/free-brands-svg-icons": "^5.15.3",
    "@fortawesome/free-regular-svg-icons": "^5.15.3",
    "@fortawesome/free-solid-svg-icons": "^5.15.3",
    "axios": "^0.21.1",
    "babel-polyfill": "^6.26.0",
    "bootstrap": "^5.0.1",
    "bootstrap.native": "^3.0.15",
    "chart.js": "^2.9.3",
    "form-serialize": "^0.7.2",
    "glightbox": "^3.0.9",
    "gulp-cli": "^2.3.0",
    "jquery": "^3.5.0",
    "jquery.dirtyforms": "^2.0.0",
    "lightbox2": "^2.9.0",
    "semantic-ui-css": "^2.2.0",
    "slick-carousel": "^1.8.1"
  },
  "devDependencies": {
    "@symfony/webpack-encore": "^1.3.0",
    "babel-core": "^6.26.3",
    "babel-plugin-external-helpers": "^6.22.0",
    "babel-plugin-module-resolver": "^3.1.1",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-register": "^6.26.0",
    "dedent": "^0.7.0",
    "eslint": "^4.19.1",
    "eslint-config-airbnb-base": "^12.1.0",
    "eslint-import-resolver-babel-module": "^4.0.0",
    "eslint-plugin-import": "^2.11.0",
    "fast-async": "^6.3.7",
    "gulp": "^4.0.2",
    "gulp-chug": "^0.5",
    "gulp-concat": "^2.6.0",
    "gulp-debug": "^2.1.2",
    "gulp-if": "^2.0.0",
    "gulp-livereload": "^4.0.1",
    "gulp-order": "^1.1.1",
    "gulp-sass": "^4.0.1",
    "gulp-sourcemaps": "^1.6.0",
    "gulp-uglifycss": "^1.0.5",
    "lodash.throttle": "^4.1.1",
    "merge-stream": "^1.0.0",
    "node-sass": "^6.0.0",
    "rollup": "^0.60.2",
    "rollup-plugin-babel": "^3.0.4",
    "rollup-plugin-commonjs": "^9.1.3",
    "rollup-plugin-inject": "^2.0.0",
    "rollup-plugin-node-resolve": "^3.3.0",
    "rollup-plugin-uglify": "^4.0.0",
    "sass-loader": "^7.0.0",
    "upath": "^1.1.0",
    "webpack-cli": "^4.7.0",
    "yargs": "^17.0.1"
  },
  "scripts": {
    "build": "gulp build",
    "gulp": "gulp build",
    "lint": "yarn lint:js",
    "lint:js": "eslint gulpfile.babel.js",
    "watch": "gulp watch"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Sylius/Sylius.git"
  },
  "author": "Paweł Jędrzejewski",
  "license": "MIT"
}

composer.json:

{
    "keywords": ["symfony", "sylius", "distribution", "ecommerce", "cart", "shopping"],
    "type": "project",
    "license": "proprietary",
    "homepage": "https://sylius.com",
    "authors": [
        {
            "name": "Paweł Jędrzejewski"
        },
        {
            "name": "Sylius project"
        },
        {
            "name": "Community contributions"
        }
    ],
    "require": {
        "php": "^7.3",
        "bitbag/payu-plugin": "^1.8",
        "friendsofsymfony/oauth-server-bundle": ">2.0.0-alpha.0 ^2.0@dev",
        "sylius/bootstrap-theme": "^0.1.2",
        "sylius/paypal-plugin": "^1.1",
        "sylius/sylius": "~1.9.0",
        "symfony/dotenv": "^4.4 || ^5.2",
        "symfony/flex": "^1.11"
    },
    "require-dev": {
        "behat/behat": "^3.7",
        "behat/mink-selenium2-driver": "^1.4",
        "dmore/behat-chrome-extension": "^1.3",
        "dmore/chrome-mink-driver": "^2.7",
        "friends-of-behat/mink": "^1.8",
        "friends-of-behat/mink-browserkit-driver": "^1.4",
        "friends-of-behat/mink-debug-extension": "^2.0",
        "friends-of-behat/mink-extension": "^2.4",
        "friends-of-behat/page-object-extension": "^0.3",
        "friends-of-behat/suite-settings-extension": "^1.0",
        "friends-of-behat/symfony-extension": "^2.1",
        "friends-of-behat/variadic-extension": "^1.3",
        "lchrusciel/api-test-case": "^5.0",
        "phpspec/phpspec": "^7.0",
        "phpstan/extension-installer": "^1.0",
        "phpstan/phpstan": "0.12.80",
        "phpstan/phpstan-doctrine": "0.12.32",
        "phpstan/phpstan-webmozart-assert": "0.12.12",
        "phpunit/phpunit": "^8.5",
        "stripe/stripe-php": "^6.43",
        "sylius-labs/coding-standard": "^3.2",
        "symfony/browser-kit": "^4.4 || ^5.2",
        "symfony/debug-bundle": "^4.4 || ^5.2",
        "symfony/intl": "^4.4 || ^5.2",
        "symfony/web-profiler-bundle": "^4.4 || ^5.2",
        "symplify/easy-coding-standard": "^8.3"
    },
    "conflict": {
        "symfony/form": "4.4.11|4.4.12"
    },
    "prefer-stable": true,
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        },
        "classmap": ["src/Kernel.php"]
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ],
        "post-create-project-cmd": [
            "@php bin/console sylius:inform-about-gus --ansi",
            "@php bin/console sylius:show-available-plugins --ansi"
        ]
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "extra": {
            "sylius-theme": {
                "title": "Crimson Theme"
            }
        },
    
        "name": "acme/crimson-theme",
        "authors": [
            {
                "name": "James Potter",
                "email": "prongs@example.com"
            }
        ]

  
}
ddrv8njm

ddrv8njm1#

这是一个老问题,但我有同样的问题。
更新生产中的节点版本,使其与本地版本相同,解决了我的问题。

相关问题