# icrc1/src/ICRC1/lib.mo:16.1-16.40: import error \[M0010\], package "StableTrieMap" not defined

**URL:** <https://forum.dfinity.org/t/icrc1-src-icrc1-lib-mo-16-1-16-40-import-error-m0010-package-stabletriemap-not-defined/18004>\
**Category:** Language Support\
**Created:** [January 16, 2023, 6:18pm UTC](https://forum.dfinity.org/t/icrc1-src-icrc1-lib-mo-16-1-16-40-import-error-m0010-package-stabletriemap-not-defined/18004 "2023-01-16T18:18:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![blabagastered](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/blabagastered/32/8592_2.png) [@blabagastered](https://forum.dfinity.org/u/blabagastered)\
**Post date:** [January 16, 2023, 6:18pm UTC](https://forum.dfinity.org/t/icrc1-src-icrc1-lib-mo-16-1-16-40-import-error-m0010-package-stabletriemap-not-defined/18004/1 "2023-01-16T18:18:51Z")

</div>

I’m trying to add an ICRC token canister to an existing project that has other canisters.

I added the token canister to dfx.json, installed mops, and on deploy of the ICRC token canister, I get

```auto
   dfx deploy icrc_token

Deploying: icrc_token
All canisters have already been created.
Building canisters...
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
  Failed to build call canisters.
    Failed while trying to build all canisters.
      The build step failed for canister 'rno2w-sqaaa-aaaaa-aaacq-cai' (icrc_token) with an embedded error: Failed to build Motoko canister 'icrc_token'.: Failed to compile Motoko.: Failed to run 'moc'.: The command '"/Users/black/.cache/dfinity/versions/0.12.1/moc" "/Users/black/icp/b/backed_usd/src/icrc_token/Main.mo" "-o" "/Users/black/icp/b/backed_usd/.dfx/local/canisters/icrc_token/icrc_token.wasm" "-c" "--debug" "--idl" "--stable-types" "--public-metadata" "candid:service" "--actor-idl" "/Users/black/icp/b/backed_usd/.dfx/local/canisters/idl/" "--actor-alias" "icrc_token" "rno2w-sqaaa-aaaaa-aaacq-cai" "--package" "base" ".mops/base@0.7.4/src" "--package" "xtended-numbers" ".mops/xtended-numbers@0.1.1/src" "--package" "itertools" ".mops/itertools@0.1.1/src"' failed with exit status 'exit status: 1'.
Stdout:

Stderr:
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:16.1-16.40: import error [M0010], package "StableTrieMap" not defined

```

This is Main.mo in src/icrc\_token in my project’s repo (I just pasted it verbatim for now): [icrc1/main.mo at main · NatLabs/icrc1 · GitHub](https://github.com/NatLabs/icrc1/blob/main/example/icrc1/main.mo)

The error arises here: [icrc1/lib.mo at c9ff6c64ee1531f33bf3d4d43bcbbbed271008af · NatLabs/icrc1 · GitHub](https://github.com/NatLabs/icrc1/blob/c9ff6c64ee1531f33bf3d4d43bcbbbed271008af/src/ICRC1/lib.mo#L16)

---

<div class="post-metadata">

**Author:** ![blabagastered](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/blabagastered/32/8592_2.png) [@blabagastered](https://forum.dfinity.org/u/blabagastered)\
**Post date:** [January 16, 2023, 7:11pm UTC](https://forum.dfinity.org/t/icrc1-src-icrc1-lib-mo-16-1-16-40-import-error-m0010-package-stabletriemap-not-defined/18004/2 "2023-01-16T19:11:44Z")

</div>

It seems to be a problem with mops. It’s not installing the packages.

This is my mops.toml

```auto
[dependencies]
base = "https://github.com/dfinity/motoko-base#moc-0.7.4"
array = "https://github.com/aviate-labs/array.mo#v0.2.0"
StableTrieMap = "https://github.com/NatLabs/StableTrieMap#main"
StableBuffer = "https://github.com/canscale/StableBuffer#v0.2.0"
xtended-numbers = "0.1.1"
itertools = "0.1.1"

[package]
name = "icrc1"
version = "0.1.0"
description = ""
repository = ""

```

and yet on deploy I get

```auto
Stdout:

Stderr:
(unknown location): package error [M0012], file ".mops/_github/StableBuffer@v0.2.0/src" (for package `StableBuffer`) does not exist
(unknown location): package error [M0012], file ".mops/_github/StableTrieMap@main/src" (for package `StableTrieMap`) does not exist
(unknown location): package error [M0012], file ".mops/_github/array@v0.2.0/src" (for package `array`) does not exist

```

---

<div class="post-metadata">

**Author:** ![Gekctek](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/gekctek/32/6863_2.png) [@Gekctek](https://forum.dfinity.org/u/Gekctek)\
**Post date:** [January 16, 2023, 7:33pm UTC](https://forum.dfinity.org/t/icrc1-src-icrc1-lib-mo-16-1-16-40-import-error-m0010-package-stabletriemap-not-defined/18004/3 "2023-01-16T19:33:11Z")

</div>

@blabagastered what happens when you run `mops install` in your project

---

<div class="post-metadata">

**Author:** ![blabagastered](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/blabagastered/32/8592_2.png) [@blabagastered](https://forum.dfinity.org/u/blabagastered)\
**Post date:** [January 16, 2023, 7:38pm UTC](https://forum.dfinity.org/t/icrc1-src-icrc1-lib-mo-16-1-16-40-import-error-m0010-package-stabletriemap-not-defined/18004/4 "2023-01-16T19:38:39Z")

</div>

It seems there was something to it because I have two repos now. The main one, that includes the ICRC token canister and others, and a separate one that is only the ICRC token.

They had gotten muddled up and when I ran `mops install` in the main one, it did install things. The other one had everything installed.

That allowed deployment of some of the canisters, but not of the ICRC token canister in the main repo. I got this error log:

```auto
black@MacBook-Pro backed_usd % dfx deploy backed_usd_icrc

Deploying: backed_usd_icrc
Creating canisters...
Creating canister backed_usd_icrc...
backed_usd_icrc canister created with canister id: rno2w-sqaaa-aaaaa-aaacq-cai
Building canisters...
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
  Failed to build call canisters.
    Failed while trying to build all canisters.
      The build step failed for canister 'rno2w-sqaaa-aaaaa-aaacq-cai' (backed_usd_icrc) with an embedded error: Failed to build Motoko canister 'backed_usd_icrc'.: Failed to compile Motoko.: Failed to run 'moc'.: The command '"/Users/black/.cache/dfinity/versions/0.12.1/moc" "/Users/black/icp/b/backed_usd/src/backed_usd_icrc/Main.mo" "-o" "/Users/black/icp/b/backed_usd/.dfx/local/canisters/backed_usd_icrc/backed_usd_icrc.wasm" "-c" "--debug" "--idl" "--stable-types" "--public-metadata" "candid:service" "--actor-idl" "/Users/black/icp/b/backed_usd/.dfx/local/canisters/idl/" "--actor-alias" "backed_usd_icrc" "rno2w-sqaaa-aaaaa-aaacq-cai" "--package" "base" ".mops/_github/base@moc-0.7.4/src" "--package" "array" ".mops/_github/array@v0.2.0/src" "--package" "StableTrieMap" ".mops/_github/StableTrieMap@main/src" "--package" "StableBuffer" ".mops/_github/StableBuffer@v0.2.0/src" "--package" "xtended-numbers" ".mops/xtended-numbers@0.1.1/src" "--package" "itertools" ".mops/itertools@0.1.1/src"' failed with exit status 'exit status: 1'.
Stdout:

Stderr:
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:346.27-346.33: type error [M0097], expected function type, but expression produces type
  Nat
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:346.33-346.34: info, this looks like an unintended function call, perhaps a missing ';'?
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:346.27-346.33: type error [M0097], expected function type, but expression produces type
  Nat
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:346.33-346.34: info, this looks like an unintended function call, perhaps a missing ';'?
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:346.34-346.49: type error [M0057], unbound variable _FFFF_FFFF_FFFF
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:354.28-354.66: type error [M0096], expression of type
  Nat__2
cannot produce expected type
  None

```

The ICRC-only repo says just:

```auto
black@MacBook-Pro icrc1 % mops install

All packages installed

```

---

<div class="post-metadata">

**Author:** ![blabagastered](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/blabagastered/32/8592_2.png) [@blabagastered](https://forum.dfinity.org/u/blabagastered)\
**Post date:** [January 16, 2023, 7:54pm UTC](https://forum.dfinity.org/t/icrc1-src-icrc1-lib-mo-16-1-16-40-import-error-m0010-package-stabletriemap-not-defined/18004/5 "2023-01-16T19:54:38Z")

</div>

Found the problem:

Part of it was that `mops install` hadn’t been run. There’s no explicit instruction to do it here [GitHub - NatLabs/icrc1: A full implementation of the ICRC-1 fungible token standard](https://github.com/NatLabs/icrc1#getting-started) nor in the mops instructions themselves: [Internet Computer Content Validation Bootstrap](https://j4mwm-bqaaa-aaaam-qajbq-cai.ic0.app/docs/install), so I didn’t do it.

And part of it was that in trying to fix this file/line [icrc1/lib.mo at c9ff6c64ee1531f33bf3d4d43bcbbbed271008af · NatLabs/icrc1 · GitHub](https://github.com/NatLabs/icrc1/blob/c9ff6c64ee1531f33bf3d4d43bcbbbed271008af/src/ICRC1/lib.mo#L16) I saved the file, and the auto-formatting-on-save tool I have (not sure which) broke the file on save.

I re-pasted the original lib.mo, saved it without formatting, and it now worked.
