---
title: "npm install error"
url: https://www.marlasowards.com/samples/contributor-guide/troubleshoot/18-npm-install-error
description: "How to fix an npm install error about an unexpected token in JSON by changing how gulpfile.ts reads docfx.json."
author: Writing sample by Marla Sowards
---

> For an index of every page on this site, see [llms.txt](https://www.marlasowards.com/llms.txt).

> **Note:** I built this project for an enterprise SaaS company. However, what I've shared is genericized to mask proprietary information, including names of companies, products, features, and UI controls. Product images are mockups generated by Claude.

# npm install error

## Symptom

The build fails with the following error:

```plaintext
SyntaxError: Unexpected token in JSON at position 0
```

## Solution

In **gulpfile.ts**, change:

```typescript
var docfxSettings = JSON.parse(fs.readFileSync('./docfx.json'));
```

to

```typescript
import * as docfxSettings from './docfx.json';
```

Next, add **tsconfig.json** at root:

```json
{
"compilerOptions": {
    "module": "commonjs",
    "target": "esnext",
    "resolveJsonModule": true
    }
}
```
