Cloudinary节点包出错 - 意外令牌

问题描述 投票:1回答:2

正如标题所述,我正在使用来自cloudinary的NPM包,我原本以为这是一个配置问题,但这是第三次现在我遇到了这个特定的错误,我似乎无法从它返回任何关于它的内容谷歌。

{ 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
2个回答
0
投票

代码正在吹嘘现代ES6传播运营商。你需要使用babel和babel-loader来编译这些模块。

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


0
投票

所以本周早些时候我遇到了类似的问题。终于找到了问题的解决方案,你可以尝试一下,看看它是否适合你。

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

干杯

© www.soinside.com 2019 - 2024. All rights reserved.