code: function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) {
          var packageJsonPath = pathToPackageJson(candidate);
          var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host);
          if (directoryExists && state.host.fileExists(packageJsonPath)) {
              if (state.traceEnabled) {
                  ts.trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
              }
              var typesFile = tryReadTypesSection(packageJsonPath, candidate, state);
              if (typesFile) {
                  var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host);
                  // A package.json "typings" may specify an exact filename, or may choose to omit an extension.
                  var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) ||
                      tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state);
                  if (result) {
                      return result;
                  }
              }
              else {
                  if (state.traceEnabled) {
                      ts.trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field);
                  }
              }
          }
          else {
              if (state.traceEnabled) {
                  ts.trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath);
              }
              // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results
              failedLookupLocation.push(packageJsonPath);
          }
          return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state);
      }
docs: /* @internal