node.js - Cloudinary Node 包错误 - 意外的 token

标签 node.js express npm babeljs cloudinary

正如标题所述,我正在使用 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 的新参数,但我似乎无法弄清楚?提前致谢!

最佳答案

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

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

关于node.js - Cloudinary Node 包错误 - 意外的 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54205028/

相关文章:

Azure上的Node.js + MongoDb,如何防止网站空闲?

node.js - 如何调试 webpack?

javascript - 使用 Node.js 上传图像时出错 - Express

javascript - 在页面加载时将正斜杠附加到 url 的末尾

javascript - react | Npm 包 - 如何导出 2 个组件以用作 npm 包

node.js - 在没有 CRLF 行终止符的 Nodejs 上创建文件

node.js - Express 4 火灾事件结束

javascript - Node/Express - res.status().send() 只发送状态但不发送对象

node.js - 如何让 npm 使用缓存

javascript - Webpack Clean-/public/js 已被删除