Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
网页包不';由于Regexp,无法编译我的javascript文件_Javascript_Jquery_Symfony4_Webpack Encore - Fatal编程技术网

网页包不';由于Regexp,无法编译我的javascript文件

网页包不';由于Regexp,无法编译我的javascript文件,javascript,jquery,symfony4,webpack-encore,Javascript,Jquery,Symfony4,Webpack Encore,我正在使用网页Encore进行Symfony 4项目。使用纱线安可开发,我得到以下错误: ERROR Failed to compile with 2 errors 11:45:38 These dependencies were not found: * core-js/modules/es.regexp.exec in ./assets/js/poteauxskip.js * core-js/modules/es.stri

我正在使用网页Encore进行Symfony 4项目。使用
纱线安可开发
,我得到以下错误:

ERROR  Failed to compile with 2 errors                                 11:45:38

These dependencies were not found:

* core-js/modules/es.regexp.exec in ./assets/js/poteauxskip.js
* core-js/modules/es.string.match in ./assets/js/poteauxskip.js

To install them, you can run: npm install --save core-js/modules/es.regexp.exec core-js/modules/es.string.match
而且Regexp表达式不起作用。我试着按照他们说的安装,但这是各种问题的开始。但主要的是,它并没有解决主要的问题,那就是:为什么这不起作用?我认为没有理由在我的javascript文件中导入任何东西来使用Regexp,我在整个解决方案研究中都没有提到这一点

poteauxskip.js文件:

const $ = require('jquery');

$(".tableau").addClass("d-none");

$(".serie").change(function(){
    updateTableaux();
});

function updateTableaux() {
    var serie1 = $("select#serie1").val() == '?' ? '[0-9A-F]' : $("select#serie1").val();
    var serie2 = $("select#serie2").val() == '?' ? '[0-9A-F]' : $("select#serie2").val();
    var serie3 = $("select#serie3").val() == '?' ? '[0-9A-F]' : $("select#serie3").val();
    var serie4 = $("select#serie4").val() == '?' ? '[0-9A-F]' : $("select#serie4").val();
    var serie5 = $("select#serie5").val() == '?' ? '[0-9A-F]' : $("select#serie5").val();
    var serie6 = $("select#serie6").val() == '?' ? '[0-9A-F]' : $("select#serie6").val();

    var regex = new Regexp("/" + serie1 + serie2 + serie3 + serie4 + serie5 + serie6 + "$/");

    alert("12".match(regex));
}
如果我测试它是否有其他东西,警报就会起作用。如果不使用任何Regexp,其他变量也可以工作。实际上,
new Regexp()
string.match()
足以导致编译错误

package.json:

{
  "devDependencies": {
    "@symfony/webpack-encore": "^0.27.0",
    "bootstrap": "^4.3.1",
    "jquery": "^3.4.1",
    "node-sass": "^4.12.0",
    "popper": "^1.0.1",
    "popper.js": "^1.15.0",
    "sass-loader": "^7.0.1",
    "webpack-notifier": "^1.6.0"
  },
  "name": "hyperbolic-world",
  "version": "2.0.0",
  "description": "Pour favoriser l'immersion dans un espace hyperbolique.",
  "main": "index.js",
  "author": "Julien Busset",
  "license": "CC-BY-4.0",
  "directories": {
    "test": "tests"
  }
}
webpack.config.js:

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

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
     *
     * Add 1 entry for each "page" of your app
     * (including one that's included on every page - e.g. "app")
     *
     * Each entry will result in one JavaScript file (e.g. app.js)
     * and one CSS file (e.g. app.css) if you JavaScript imports CSS.
     */
    .addEntry('app', './assets/js/app.js')
    .addEntry('poteauxskip', './assets/js/poteauxskip.js')
    //.addEntry('page1', './assets/js/page1.js')
    //.addEntry('page2', './assets/js/page2.js')

    // 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())

    // enables @babel/preset-env polyfills
    .configureBabel(() => {}, {
        useBuiltIns: 'usage',
        corejs: 3
    })

    // enables Sass/SCSS support
    .enableSassLoader()
    //.addStyleEntry('global', './assets/scss/global.scss')

    // uncomment if you use TypeScript
    //.enableTypeScriptLoader()

    // uncomment to get integrity="..." attributes on your script & link tags
    // requires WebpackEncoreBundle 1.4 or higher
    //.enableIntegrityHashes()

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

    // uncomment if you use API Platform Admin (composer req api-admin)
    //.enableReactPreset()
    //.addEntry('admin', './assets/js/admin.js')
;

module.exports = Encore.getWebpackConfig();

通过添加core js和
纱线添加core js--dev

解决问题通过添加core js和
纱线添加core js--dev

解决问题我刚刚尝试了
纱线添加core js
,我不再有编译问题。我只是尝试了
纱线添加core js
,我不再有编译问题了,但我还有另一个问题,那就是
新的Regexp
不起作用,阻塞了进一步的指令。但是,
string.match(any_regex)
可以工作,所以它更好。但是我还有另一个问题,那就是
new Regexp
不能工作并阻止进一步的指令。但是,
string.match(任何正则表达式)
都可以工作,所以它更好。