Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module '@actions/core' - when running my GitHub Action from another repo

I have made a GitHub Action in a private repo:

import * as core from '@actions/core';
import * as github from '@actions/github';

async function run() {
  try {
  } catch (error) {
    if (error instanceof Error) {
      core.setFailed(error.message);
    } else {
      core.setFailed('Unknown error has occurred: ' + error);
    }
  }
}

run();

When I run this action from another private repo I get the following error:

Error: Cannot find module '@actions/core'

I don't get this error in Visual Studio Code, only when running the Action on GitHub.

All the modules are installed, I have even built into JS file but still get the error, and my TypeScript config is correct also. Any ideas?

Action:
    name: 'Action'
    description: 'GitHub Action.'
    author: 'G'
    inputs: {}
    runs:
      using: 'node16'
      main: 'dist/main.js'

tsconfig.json:

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "moduleResolution": "node",
    "outDir": "dist"
  },
  "include": ["./*.ts"],
  "exclude": ["node_modules"]
}
like image 819
George Avatar asked Oct 21 '25 03:10

George


1 Answers

You simply need to install the node package:

npm i @actions/core

Edit: do the same for @actions/github, it'll error too

like image 74
HyperCodec Avatar answered Oct 22 '25 19:10

HyperCodec



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!