Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.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
Javascript 无法要求带网页包的Popper_Javascript_Ruby On Rails_Webpack_Webpacker - Fatal编程技术网

Javascript 无法要求带网页包的Popper

Javascript 无法要求带网页包的Popper,javascript,ruby-on-rails,webpack,webpacker,Javascript,Ruby On Rails,Webpack,Webpacker,我正在尝试将我的javascript文件移动到Webpack。我不是很熟悉网页,所以我不确定我是否正确地编码了这些内容。我正在尝试加载jqueryui、popper和bootstrap4。但是,我在要求Popper时遇到了一个错误。请注意,我使用的是用于Ruby on Rails的Wepacker gem 我在environment.js文件中包含了以下代码,以便在每个文件中自动包含jQuery const { environment } = require('@rails/webpacker'

我正在尝试将我的javascript文件移动到Webpack。我不是很熟悉网页,所以我不确定我是否正确地编码了这些内容。我正在尝试加载jqueryui、popper和bootstrap4。但是,我在要求Popper时遇到了一个错误。请注意,我使用的是用于Ruby on Rails的Wepacker gem

我在environment.js文件中包含了以下代码,以便在每个文件中自动包含jQuery

const { environment } = require('@rails/webpacker')

const webpack = require('webpack')
environment.plugins.append('Provide', new webpack.ProvidePlugin({
  $: 'jquery',
  jQuery: 'jquery'
}))

module.exports = environment
这部分是有效的。因此,我在那里运行了添加jqueryui的程序

然后在我的/pack/application.js文件中,我包含了require'jquery-ui'

从我的js文件中,以下代码打印到我的控制台:

$(document).ready(function(){
    if (jQuery.ui) {
      console.log("loaded");
    }
});
在此之后,我试图安装和要求与纱线添加波普尔波普尔波普尔

然后从我的document.ready函数中调用popper,我得到一个错误:

$(document).ready(function(){

    console.log(window.Popper)

});
错误:

Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /home/ubuntu/environment/node_modules/path-platform/path.js: 'return' outside of function (32:2)

  30 | if (_path.posix) {
  31 |   module.exports = _path;
  32 |   return;
     |   ^
  33 | }
  34 | 
  35 | // resolves . and .. elements in a path array with directory names there
    at Parser.raise (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:6420)
    at Parser.parseReturnStatement 
(home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10370)
    at Parser.parseStatementContent 
(home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10057)
    at Parser.parseStatement (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10009)
    at Parser.parseBlockOrModuleBlockBody 
(home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10585)
    at Parser.parseBlockBody (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10572)
    at Parser.parseBlock (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10556)
    at Parser.parseStatementContent 
    (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10085)
    at Parser.parseStatement (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10009)
    at Parser.parseIfStatement 
    (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10363)
    at Parser.parseStatementContent 
    (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10054)
    at Parser.parseStatement (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10009)
    at Parser.parseBlockOrModuleBlockBody 
    (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10585)
at Parser.parseBlockBody (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10572)
at Parser.parseTopLevel (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:9940)
at Parser.parse (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:11447)
at parse (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:11483)
at parser (home/ubuntu/environment/node_modules/@babel/core/lib/transformation/normalize-file.js:168)
at normalizeFile (home/ubuntu/environment/node_modules/@babel/core/lib/transformation/normalize-file.js:102)
at runSync (home/ubuntu/environment/node_modules/@babel/core/lib/transformation/index.js:44)
at runAsync (home/ubuntu/environment/node_modules/@babel/core/lib/transformation/index.js:35)
at process.nextTick (home/ubuntu/environment/node_modules/@babel/core/lib/transform.js:34)
at process._tickCallback (internal/process/next_tick.js:61)
at Object../node_modules/path-platform/path.js (index.js:82)
at __webpack_require__ (bootstrap:19)
at Object.<anonymous> (index.js:1)
at Object../node_modules/parents/index.js (index.js:39)
at __webpack_require__ (bootstrap:19)
at Object.<anonymous> (index.js:19)
at Object../node_modules/module-deps/index.js (index.js:623)
at __webpack_require__ (bootstrap:19)
at Object.<anonymous> (index.js:3)
at Object../node_modules/browserify/index.js (index.js:846)

我只是做了同样的事情,然后意识到问题是什么。是节点中的某种高级浏览器测试库。引导依赖于,它是浏览器的工具提示弹出库

因此,要解决此问题,您需要:

yarn remove popper
yarn add popper.js
yarn remove popper
yarn add popper.js