正如标题所述,我正在使用 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/