matrix-appservice-irc
matrix-appservice-irc copied to clipboard
`yarn` fails due to import issue
$ yarn
yarn install v1.22.19
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
success Saved lockfile.
$ yarn run build
yarn run v1.22.19
$ yarn run build:app && yarn run build:widget
$ tsc --project ./tsconfig.json
src/models/MatrixAction.ts:19:1 - error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
19 import ircFormatting = require("../irc/formatting");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in src/models/MatrixAction.ts:19
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
I fixed this by changing that line
$ git diff src/
diff --git a/src/models/MatrixAction.ts b/src/models/MatrixAction.ts
index e213aeb4..fbdc38b4 100644
--- a/src/models/MatrixAction.ts
+++ b/src/models/MatrixAction.ts
@@ -16,7 +16,7 @@ limitations under the License.
import { IrcAction } from "./IrcAction";
-import ircFormatting = require("../irc/formatting");
+import * as ircFormatting from "../irc/formatting";
import { ContentRepo, Intent } from "matrix-appservice-bridge";
import escapeStringRegexp from "escape-string-regexp";
import logging from "../logging";
Is this on latest develop? You have a:
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
warning which implies you either ran npm, or are on a older version of the bridge.
The import itself looks sloppy, but we're not targetting modules (rather, commonjs) so I think there might be something up with your environment.
I was on 1.0.1 tag, but this line is there in develop also https://github.com/matrix-org/matrix-appservice-irc/blob/develop/src/models/MatrixAction.ts