# Fix ESX Is Nil / getSharedObject Errors (/docs/getting-started/esx-is-nil)

If your console reports **`ESX is nil`**, **`attempt to index a nil value (global 'ESX')`** or **`No such export getSharedObject`**, inspect the resource import and whether `es_extended` is running.

## Recommended fix — import ESX in your manifest [#recommended-fix--import-esx-in-your-manifest]

```lua title="fxmanifest.lua"
fx_version 'cerulean'
game 'gta5'

shared_scripts {
    '@es_extended/imports.lua',
    'config.lua',
}

client_script 'client.lua'
server_script 'server.lua'
dependency 'es_extended'
```

The import makes `ESX` available on both sides, but **server-only APIs must still run on the server**. The import must be loaded before your resource's own files.

Alternatively, retrieve the export after the framework loads:

```lua
local ESX = exports['es_extended']:getSharedObject()
```

## Has `esx:getSharedObject` really been removed? [#has-esxgetsharedobject-really-been-removed]

**No.** The maintained ESX Legacy 1.16.4 source still registers this event for backward compatibility:

```lua
local ESX
TriggerEvent('esx:getSharedObject', function(object)
    ESX = object
end)
```

It is a legacy pattern. Prefer `@es_extended/imports.lua` or `exports['es_extended']:getSharedObject()` for new code, but do not claim that the old event no longer exists.

## Troubleshoot the exact message [#troubleshoot-the-exact-message]

### `attempt to index a nil value (global 'ESX')` [#attempt-to-index-a-nil-value-global-esx]

1. Check the `shared_scripts` entry and its order.
2. Add `dependency 'es_extended'` in `fxmanifest.lua`.
3. Confirm that `es_extended` started without errors.
4. Search for a conflicting or uninitialized `local ESX` variable.

### `No such export getSharedObject in resource es_extended` [#no-such-export-getsharedobject-in-resource-es_extended]

Check the `es_extended` folder name, whether its `fxmanifest.lua` is at the correct level and whether the core actually started. The export exists in the maintained source; startup failures can prevent it becoming available.

### `Couldn't load resource es_extended` [#couldnt-load-resource-es_extended]

Look for the first server error rather than changing the export call. Dependencies such as `esx_lib` and `oxmysql` may be missing. See [ESX troubleshooting](/docs/getting-started/troubleshooting).

### `ESX.GetPlayerFromId is nil` [#esxgetplayerfromid-is-nil]

`ESX.GetPlayerFromId` is a **server-side** function. Use the [server API](/docs/es_extended/server/functions) on the server and the [client API](/docs/es_extended/client/functions) on the client.

## Related [#related]

- [ESX troubleshooting](/docs/getting-started/troubleshooting)
- [Server startup order](/docs/getting-started/server-cfg)
- [Convert old ESX scripts](/docs/guides/convert-old-esx-scripts)
- [Your first ESX resource](/docs/getting-started/first-resource)
