error TS2503: Cannot find namespace 'Now'.

Jon G Lind
ServiceNow Employee
ServiceNow Employee

I recently encountered this issue when I tried to use a type from sdk/core in a TypeScript file in the server directory.

 

I had taken the existing file `/src/fluent/server/script.ts` and added an import from @Servicenow/sdk/core and all of a sudden now-sdk builds started failing, starting with the following errors.

node_modules/@servicenow/sdk-core/src/db/Table.ts:4:31 - error TS2503: Cannot find namespace 'Now'.
export type TableName = keyof Now.Internal.Tables

 

We're used to using the core libraries in Fluent (e.g. Record or BusinessRule) but in order to do so you must make sure that the first line of the file imports the @Servicenow/sdk/global library before importing sdk/core, like this:

import '@servicenow/sdk/global' // Don't forget this
import { GlideRecord } from '@servicenow/sdk/core' // If you're going to add this
import { gs } from '@servicenow/glide'

 

1 ACCEPTED SOLUTION

Jon G Lind
ServiceNow Employee
ServiceNow Employee

Added import of @Servicenow/sdk/global to fix it.

View solution in original post

1 REPLY 1

Jon G Lind
ServiceNow Employee
ServiceNow Employee

Added import of @Servicenow/sdk/global to fix it.