# Yarn Failed to build

## Build / Startup Error Fix

If you see errors like these while starting `op-crime`, the issue is usually caused by **outdated artifacts**, not by the resource itself.

### Example errors

#### Yarn / build error

```
Running build tasks on resource op-crime - it'll restart once completed.
Couldn't start resource op-crime.
[yarn] yarn install v1.22.5
[yarn] [1/4] Resolving packages...
[yarn] success Already up-to-date.
[yarn] Done in 0.06s.
[yarn] Error: Assertion failed: 0 (../deps/uv/src/unix/core.c: uv_close: 234)
Building resource op-crime failed.
Error data: yarn failed!
```

#### Missing module error

```
Error loading script server/server.js in resource op-crime: Error: Cannot find module 'image-js'
Require stack:
- ./QBox Passion Project/txData/qbox_7BFF69.base/resources/[gangs]/op-crime/dummy.js
```

***

### Primary fix

In most cases, the correct fix is to **update your server artifacts**.

`op-crime` may fail to build or start properly on older artifacts.\
Before troubleshooting Yarn, Node, or dependencies, make sure you are running a **recent artifact version**.

You can check the latest recommended artifacts here:

[**https://artifacts.jgscripts.com/**](https://artifacts.jgscripts.com/)

Use that page to see which artifacts are currently up to date and do not have reported issues.

***

## Why this happens

These errors often appear because the server is running on **older or problematic artifacts** that are not fully compatible with the resource build process.

This can result in issues such as:

* `yarn failed`
* `uv_close: 234`
* `Cannot find module ...`
* resource build failures
* startup crashes during dependency handling

Even if the resource files are correct, outdated artifacts can still cause the resource to fail.

***

## Recommended fix order

### 1. Update artifacts first

Before changing anything in the resource itself, update your server artifacts to a newer stable version.

#### What to do

1. Check your current artifact version
2. Visit [**artifacts.jgscripts.com**](https://artifacts.jgscripts.com/)
3. Compare your current version with the latest recommended ones
4. Update to a newer artifact that has no reported issues
5. Restart the server and test `op-crime` again

Do this before reinstalling packages or editing dependencies.

***

### 2. Restart the resource after updating

After updating artifacts, restart the whole server or run:

```
ensure op-crime
```

If the resource starts correctly after the artifact update, no further action is needed.

***

## If the issue still happens after updating artifacts

If you already updated artifacts and the issue continues, follow the steps below.

***

### Reinstall dependencies

Go to the resource folder (this is example, use real directory on your server):

```
resources/[gangs]/op-crime
```

Remove old install files:

```
rm -rf node_modules
rm -f yarn.lock
rm -f package-lock.json
```

Then reinstall:

```
yarn install
```

If needed, clean the Yarn cache first:

```
yarn cache clean
yarn install
```

***

### Fix `Cannot find module 'image-js'`

If you still get this error after updating artifacts, install the missing package manually:

```
yarn add image-js
```

Or with npm:

```
npm install image-js
```

Then restart the resource.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.otherplanet.dev/scripts/op-gangs/tutorials/yarn-failed-to-build.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
