NodeJs: TypeError:First argument must be file descriptor

  node.js, question
var fs = require('fs')
 
 Fs.open('../src/urls.js', 'w plus', function(err, fd) {
 fs.write(fd, 'const DEV = false\r\n', 0, function(err, bytes) {
 })
 })

Why does this code prompt when executingTypeError:First argument must be file descriptorClearly fd is the descriptor from open. solve

Judge whether the opening failed. If the opening failed, fd is definitely not a file descriptor.

var fs = require('fs')
 
 Fs.open('../src/urls.js', 'w plus', function(err, fd) {
 if(err!  ==null){
 console.error(err);
 return;
 bracket
 fs.write(fd, 'const DEV = false\r\n', 0, function(err, bytes) {
 if(err!  ==null){
 console.error(err);
 return;
 bracket
 });
 })