TS2307: Cannot find module or its corresponding type declarations
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
Hi there. I'm currently developing custom github action with typescript and I want to use npm package inside of action project. But unfortunately, I get "TS2307: Cannot find module 'typescript-json-serializer' or its corresponding type declarations" error when running github action runner runs tsc -p tsconfig.json. I tested this build on my PC with Windows 10 OS and in Ubuntu 20.04 server and it works fine.
My .github/workflows/generator.yml
name: Generator
on:
push:
branches:
- develop
paths:
- 'src/**/*.ts'
- 'github-actions/**/*.*'
- '.github/workflows/**/*.*'
pull_request:
branches:
- develop
jobs:
generator:
name: Libraries generating action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use NodeJS 16.X
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Switch npm package repository
run: cd github_actions && npm config set registry https://registry.npmjs.org/
- name: Install dependencies
run: cd github_actions && npm i
- name: Install serializer
run: cd github_actions && npm i --save typescript-json-serializer
- name: Test
run: cd github_actions && cat package.json && cat package-lock.json
- name: Build
run: cd github_actions && npm run build
- name: Run generator action
uses: ./github_actions/
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
COMMIT_AUTHOR: ${{ github.event.head_commit.author }}
- uses: EndBug/add-and-commit@v9
with:
message: "style: generate new scheme and raise package version"
committer_name: Lauriero
committer_email: incorobots@gmail.com
My package.json
{
"name": "github-actions",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"build": "tsc -p tsconfig.json"
},
"author": "Lauriero",
"license": "ISC",
"devDependencies": {
"@types/node": "^17.0.30",
"typescript": "^4.6.4"
},
"dependencies": {
"@actions/core": "^1.7.0",
"@actions/github": "^5.0.1",
"discord-webhook-ts": "^5.0.0",
"reflect-metadata": "^0.1.13",
"typed-github-api": "^1.2.6",
"typescript-json-serializer": "^4.1.1"
}
}
My tsconfig.json
{
"compilerOptions": {
"types": [
"node",
"reflect-metadata",
"typescript-json-serializer"
],
"allowJs": true,
"target": "ESNext",
"outDir": "dist",
"module": "commonjs",
"lib": ["ESNext"],
"strict": true,
"skipLibCheck": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/*.spec.ts"]
}
Also package.json and package-lock.json in runner environment have typescript-json-serializer installed.
As you can see, I make runner install this package manually but it doesn't help.
Any help would be appreciated.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with .github/workflows/generator.yml and compare its dependency installation and build steps with package.json and tsconfig.json. Reproduce the runner's npm run build and compare it with the reported local builds. Done means the GitHub Actions build resolves the typescript-json-serializer import without TS2307.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, typescript
- Domain
- ci-cd
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100