question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error in jest dep. during serverless npm build

See original GitHub issue

🐛 Bug Report

Hello, I’m trying to build a project which have jest as dependency. It’s a Create React App based project. I’m building the process through a serverless CI/CD for AWS Lambda environment (it launches a simple npm i / npm run build). Two days ago I successfully deployed the project with no errors. Today I’m getting an error during the build process at the following line in the jest-diff module:

import type { DiffOptions } from './types';

In the package.json file I’ve got the following dependencies configuration:

  • TypeScript version 3.5.2
  • Jest: 24.0.15

the same configuration of the last succesful build of two days ago. I encounter the problem only in the AWS infrastructure, not locally. Thanks in advance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
thymikeecommented, May 13, 2020

@jberube we don’t control @types/jest, feel free to raise the issue there 😃

1reaction
jberubecommented, May 13, 2020

@thymikee jest-diff@26.0.1 is imported from @types/jest@24.0.15 (see below).

That caused my project to break with the error mentioned in OP.

Upgrading to typescript@3.8 comes with a host of issues in some projects, since not all libraries supports it well at the moment. In my case, jest wasn’t importing non-ES5 or non-js modules correctly using react-scripts@3.4.1 with default configurations after updating to typescript@3.8.

As a workaround, downgrading jest-diff@24.9.0 works pretty well.

@types/jest-diff@24.x probably shouldn’t import jest-diff@26.0.1 and import jest-diff@24.9.0 instead.

EDIT: updating @types/jest@24.9.1 work and is clean. My types were out of date. My bad 😛


> npm ls jest-diff
...
├─┬ @types/jest@24.0.15
│ └─┬ @types/jest-diff@24.3.0
│   └── jest-diff@26.0.1
└─┬ react-scripts@3.0.1
  └─┬ jest@24.7.1
    └─┬ jest-cli@24.9.0
      └─┬ @jest/core@24.9.0
        └─┬ jest-snapshot@24.9.0
          ├── jest-diff@24.9.0
          └─┬ jest-matcher-utils@24.9.0
            └── jest-diff@24.9.0
Read more comments on GitHub >

github_iconTop Results From Across the Web

npm install errors with Error: ENOENT, chmod - Stack Overflow
I noticed that the error had to do with the file I am linking to the path, specifically when npm tried to do...
Read more >
depcheck - npm
Depcheck is a tool for analyzing the dependencies in a project to see: how each dependency is used, which dependencies are useless, and...
Read more >
Unit testing for Node.js Serverless projects with Jest
Create unit tests for Node.js using the Serverless Framework, run tests on CI, ... I'm a huge Jest fan when it comes to...
Read more >
Troubleshooting - Puppeteer
PUPPETEER_CACHE_DIR=$(pwd) npm install puppeteer ... Lastly, if you're using Puppeteer through Jest, then you may encounter an error spawning child ...
Read more >
Unit Tests in Serverless - SST.Dev - Netlify
However, if you are starting a new Serverless Framework project, add Jest to your dev dependencies by running the following. Copy $ npm...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found