Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.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 使用条带签出时,由于加载程序的原因,获取未扩展的令牌导致错误_Javascript_Node.js_Vue.js_Webpack - Fatal编程技术网

Javascript 使用条带签出时,由于加载程序的原因,获取未扩展的令牌导致错误

Javascript 使用条带签出时,由于加载程序的原因,获取未扩展的令牌导致错误,javascript,node.js,vue.js,webpack,Javascript,Node.js,Vue.js,Webpack,我试图将条带签出集成到VueJS应用程序中,但在应用程序编译时出现以下错误: ERROR in ./node_modules/stripe/lib/utils.js Module parse failed: Unexpected token (152:24) You may need an appropriate loader to handle this file type. | opts.auth = args.pop(); | } else if (utils.

我试图将条带签出集成到VueJS应用程序中,但在应用程序编译时出现以下错误:

ERROR in ./node_modules/stripe/lib/utils.js
Module parse failed: Unexpected token (152:24)
You may need an appropriate loader to handle this file type.
|         opts.auth = args.pop();
|       } else if (utils.isOptionsHash(arg)) {
|         const params = {...args.pop()};
| 
|         const extraKeys = Object.keys(params).filter(
 @ ./node_modules/stripe/lib/stripe.js 44:14-32
 @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/app/CMS/eCommerce/Checkout.vue
 @ ./src/app/CMS/eCommerce/Checkout.vue
 @ ./src/routes.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8082 webpack/hot/dev-server ./src/main.js
当我将以下变量添加到mt Checkout.vue文件时会发生这种情况

从“条带”导入条带; 常量条带=条带('MYAPI')

这是我们的网页文件

var path = require('path')
var webpack = require('webpack')

module.exports = {
  entry: './src/main.js',
  output: {
    filename: 'build.js',
    path: path.resolve(__dirname, './dist'),
    publicPath: '/dist/'
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'vue-style-loader',
          'style-loader',
          'css-loader'
        ],
      },
      {
        test: /\.html$/i,
        loader: 'html-loader',
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
          }
          // other vue-loader options go here
        }
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'file-loader',
        options: {
          name: '[name].[ext]?[hash]',
          outputPath: 'assets/images/'
        }
      }
    ]
  },
  resolve: {
    alias: {
      'vue$': 'vue/dist/vue.esm.js'
    },
    extensions: ['*', '.js', '.vue', '.json']
  },
  devServer: {
    historyApiFallback: true,
    noInfo: true,
    overlay: true,
  },
  performance: {
    hints: false
  },
  devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
  module.exports.devtool = '#source-map'
  // http://vue-loader.vuejs.org/en/workflow/production.html
  module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      compress: {
        warnings: false
      }
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true
    })
  ])
}

任何建议都很好。谢谢

在我看来,文件
/src/app/CMS/eCommerce/Checkout.vue
似乎出了问题

第一:两个变量argargs真的存在吗

第二:为了使语法
params={…args.pop()}
工作
args
mus必须是一个对象数组

第三:你有babel配置文件吗?因为我认为您需要巴贝尔预设“@babel/preset env”或一些巴贝尔插件,如“@babel/plugin proposition object rest spread”和“@babel/plugin transform spread”,以便巴贝尔为浏览器传输代码

最小的babel.config.js可以如下所示:

module.exports = api => {
    api.cache(true);

    const presets = [];
    const plugins = [];

    /*
    // If you want to transpile just some syntaxes manually - micromanagement
    plugins.push(
        [ "@babel/plugin-transform-block-scoping" ],
        [ "@babel/plugin-proposal-object-rest-spread" ],
        [ "@babel/plugin-transform-classes" ],
        [ "@babel/plugin-transform-spread" ],
        [ "@babel/plugin-transform-destructuring" ],
        [ "@babel/plugin-transform-for-of" ],
        [ "@babel/plugin-transform-template-literals" ],
        [ "@babel/plugin-transform-arrow-functions", { spec: false } ],
    );
    */
    
    // Or let babel transpile everthing
    presets.push(
        [ "@babel/preset-env" ]
    )

    return {
        presets,
        plugins
    }
}

首先,您正在运行node.js的哪个版本。。。。第152行的
/node\u modules/stripe/lib/utils.js
中可能有一些错误?也许你的node.js版本不理解
(在本例中,rest in objects)嗨@JaromandaX谢谢你的反馈,我正在运行node v14.11.0,无法找出我的vue应用程序中读取rest in objects缺少的加载程序。嗨@kossi谢谢你的评论和反馈,我很感激。当我将stripe导入checkout.vue文件时,
params={…args.pop()}
来自utils/stripe fnc。另外,我正在使用webpack,我尝试将
“@babel/plugin proposition object rest spread”
添加到它,而不对错误消息进行任何更改。哦,好的-因此utils/stripe函数在node_模块下。但您将webpack配置为忽略node_modules
exclude:/node_modules/
下的所有内容,因此它们将不会被传输。。。尝试
/node\u modules\/(?!(stripe)\/).*/
让webpack忽略node\u modules下的所有内容,但stripe包。。。我希望它能奏效