cloudinary_npm
cloudinary_npm copied to clipboard
fix: 'os.tmpDir is not a function' on recent Node versions
Brief Summary of Changes
- Using Node version 16.16.0 and likely lower major Node versions, there is an
osmodule breaking change whereos.tmpDir()is nowos.tmpdir()when running on macOS 10.15.1. - This appears to be resolved and/or handled by a more recent version of the connect-multiparty module.
- Upgrading it reveals a small incompatibility where
req.files.image.ws.bytesWrittenis no longer available, so, a potential guess solution has been applied by usingreq.files.image.sizeinstead. - Error observed when uploading a photo via the
Add photobutton on the photo-album sample:
TypeError: os.tmpDir is not a function
at new Form (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/multiparty/index.js:55:44)
at multipart (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/connect-multiparty/index.js:56:16)
at Layer.handle [as handle_request] (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/route.js:144:13)
at Route.dispatch (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/route.js:114:3)
at Layer.handle [as handle_request] (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/layer.js:95:5)
at /Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/index.js:284:15
at Function.process_params (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/index.js:346:12)
at next (/Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/node_modules/express/lib/router/index.js:280:10)
at /Users/kevinreilly/Development/cloudinary_npm/samples/photo_album/server.js:53:7
What Does This PR Address?
- [ ] GitHub issue (Add reference - #XX)
- [ ] Refactoring
- [ ] New feature
- [x] Bug fix
- [ ] Adds more tests
Are Tests Included?
- [ ] Yes
- [x] No
Reviewer, Please Note:
Decision to replace req.files.image.ws.bytesWritten with req.files.image.size may not be correct as the former no longer appears to be available with an upgraded version of connect-multiparty, though I'm not certain this meets the original expectations of evaluating the bytesWritten.