Bonjour,

Je viens d'installer pour la premiere fois webpack/encore + bootstrap 5 dans mon projet (déja existant)
J'ai donc bien installé node.js / yarn / npm / PostCSS via des npm install etc.
(j'ai globalement suivit cette vidéo: [(https://www.youtube.com/watch?v=Q0gBWIvzuEw&t=803s&ab_channel=yoandevco)] )
Mais à la suite de cette procédure, en vérifiant dans ma console je tombe sur une erreur qui est la suivante :

[Uncaught Error: Cannot find module '@popperjs/core'
at webpackMissingModule (vendors-node_modules_symfony_stimulus-bridge_dist_index_js-node_modules_bootstrap_dist_js_boo-6a5154.js:2989)
at Object../node_modules/bootstrap/dist/js/bootstrap.esm.js (vendors-node_modules_symfony_stimulus-bridge_dist_index_js-node_modules_bootstrap_dist_js_boo-6a5154.js:2989)
at webpack_require__ (bootstrap:18)
at Object../assets/app.js (hello_controller.js:66)
at
webpack_require__ (bootstrap:18)
at checkDeferredModulesImpl (jsonp chunk loading:71)
at webpackJsonpCallback (jsonp chunk loading:53)
at app.js:1
]

Je sais qu'il me dit ne pas trouver le poppersjs/core, mais je le vois bien dans mes dependencies d'ou mon interrogation..

Auriez-vous une idée d'ou cela pourrait venir?

Voici mon package.json

{
'package.json'

    "devDependencies": {
        "@symfony/stimulus-bridge": "^2.0.0",
        "@symfony/webpack-encore": "^1.1.2",
        "autoprefixer": "^10.2.4",
        "core-js": "^3.0.0",
        "jquery": "^3.6.0",
        "popper.js": "^1.16.1",
        "postcss-loader": "^5.0.0",
        "regenerator-runtime": "^0.13.2",
        "sass": "^1.32.8",
        "sass-loader": "11.0.0",
        "stimulus": "^2.0.0",
        "webpack-notifier": "^1.6.0"
    },
    "license": "UNLICENSED",
    "private": true,
    "scripts": {
        "dev-server": "encore dev-server",
        "dev": "encore dev",
        "watch": "encore dev --watch",
        "build": "encore production --progress"
    },
    "dependencies": {
        "@popperjs/core": "^2.9.0",
        "bootstrap": "^5.0.0-beta2"
    }
}

Voici mon webpack.config.js

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

// Manually configure the runtime environment if not already configured yet by the "encore" command.
// It's useful when you use tools that rely on webpack.config.js file.
if (!Encore.isRuntimeEnvironmentConfigured()) {
    Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}

Encore
    // directory where compiled assets will be stored
    .setOutputPath('public/build/')
    // public path used by the web server to access the output path
    .setPublicPath('/build')
    // only needed for CDN's or sub-directory deploy
    //.setManifestKeyPrefix('build/')

    /*
     * ENTRY CONFIG
     *
     * Each entry will result in one JavaScript file (e.g. app.js)
     * and one CSS file (e.g. app.css) if your JavaScript imports CSS.
     */
    .addEntry('app', './assets/app.js')

    // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
    .enableStimulusBridge('./assets/controllers.json')

    // When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
    .splitEntryChunks()

    // will require an extra script tag for runtime.js
    // but, you probably want this, unless you're building a single-page app
    .enableSingleRuntimeChunk()

    /*
     * FEATURE CONFIG
     *
     * Enable & configure other features below. For a full
     * list of features, see:
     * https://symfony.com/doc/current/frontend.html#adding-more-features
     */
    .cleanupOutputBeforeBuild()
    .enableBuildNotifications()
    .enableSourceMaps(!Encore.isProduction())
    // enables hashed filenames (e.g. app.abc123.css)
    .enableVersioning(Encore.isProduction())

    .configureBabel((config) => {
        config.plugins.push('@babel/plugin-proposal-class-properties');
    })

    // enables @babel/preset-env polyfills
    .configureBabelPresetEnv((config) => {
        config.useBuiltIns = 'usage';
        config.corejs = 3;
    })

    // enables Sass/SCSS support
    .enableSassLoader()

    // uncomment if you're having problems with a jQuery plugin
    .autoProvidejQuery()
;

module.exports = Encore.getWebpackConfig();

Mon app.js

// any CSS you import will output into a single css file (app.css in this case)
import './styles/app.scss';

import { Tooltip, Toast, Popover } from 'bootstrap';

import 'popper.js';

// start the Stimulus application
import './bootstrap';

import 'bootstrap';

Merci pour vos retours

2 réponses


Hello,

    yarn add @popperjs/core

Hello,
Merci pour ton retour. J'ai lancé la commande + un install pour mettre à jour et j'ai toujours le même résultat..