【问题标题】:Error from Cloudinary node package - Unexpected TokenCloudinary 节点包中的错误 - 意外令牌
【发布时间】:2019-06-09 19:54:11
【问题描述】:

正如标题所说,我使用的是 cloudinary 的 NPM 包,我原本以为是配置问题,但这是我第三次遇到这个特定错误,我似乎无法返回任何东西来自 Google。

{ fieldname: 'name-of-input-key',
  originalname: 'leaf.png',
  encoding: '7bit',
  mimetype: 'image/png' }
file uploaded to server
{ fieldname: 'name-of-input-key',
  originalname: 'leaf.png',
  encoding: '7bit',
  mimetype: 'image/png',
  destination: 'uploads/',
  filename: 'leaf.png',
  path: 'uploads/leaf.png',
  size: 10227 }
/home/nolan/Node/cloudinary-skel/node_modules/cloudinary/lib/utils/index.js:989
  return {...hash1, ...hash2};
          ^^^

SyntaxError: Unexpected token ...
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/nolan/Node/cloudinary-skel/node_modules/cloudinary/lib/cloudinary.js:4:17)

我假设它没有运行 Babel 或其他东西,因为这些参数对 ES6 来说是新的,但我似乎无法弄清楚?提前致谢!

【问题讨论】:

    标签: node.js express npm babeljs cloudinary


    【解决方案1】:

    代码在现代 ES6 扩展运算符上崩溃了。你需要使用 babel 和 babel-loader 来编译这些模块。

    您需要共享您的 package.json 和 webpack.conifg.js 的配置。

    【讨论】:

      【解决方案2】:

      所以本周早些时候我遇到了类似的问题。终于找到了解决问题的办法,你可以试试这个,看看它是否适合你。

      所以,我在 package.json 文件中指定了 engines,并将其设置为版本 8,但将其更改为版本 10 后,一切正常。

      干杯

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-07-06
        • 1970-01-01
        • 2023-03-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-09-25
        相关资源
        最近更新 更多