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.

danger pr throwing "Cannot find module 'package.json'"

See original GitHub issue

👋 I’m currently trying to add danger to my project. I’ve set up my dangerfile.js as so:

const { danger, fail } = require('danger')

const someoneAssigned = danger.github.pr.assignee
if (someoneAssigned === null) {
  fail("Please assign someone to merge this PR, and optionally include people who should review.")
}

and if I run danger pr I get back an error:

> danger pr https://github.com/artsy/positron/pull/1
(node:97283) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: Cannot find module 'package.json'
(node:97283) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I have danger installed both globally and to my project repo. My local version of Node is v7.10.0. Any thoughts?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
threevecommented, Jun 14, 2017

This really bummed me out just now trying to set up danger on our project finally. Until the new version of Jest is released it seems that a simple workaround is to ensure you have a .babelrc file in your project containing simply an empty json object {}. With that in place I’m able to get danger working both on jenkins and locally with danger pr 👍

1reaction
hramoscommented, Jul 12, 2017

I’ve been running into this as well. Looks like this is fixed in jest#master, and the fix is available in Jest 20.1.0-alpha.3. I’m guessing we won’t want to move Danger to an alpha release just yet, so we’ll need to wait for the final Jest 20.1.0 release to become available.

Read more comments on GitHub >

github_iconTop Results From Across the Web

6 - Stack Overflow
However, every time I install something globally, it does not update the package.json file, but does install it in /usr/local/lib/node_modules.
Read more >
Solved: CLD200 - Manual Deployment keeps erroring out
When I run the cf push command, I get the below error: user: risk-management $ cf ... Installing node modules (package.json + package-lock.json)....
Read more >
patch-package - npm
json. If it's a transitive dependency patch-package can't detect that it is safe to ignore and will throw an error. To fix this,...
Read more >
Danger JS
Danger is a NPM module that evals a Dangerfile . You set up a Dangerfile per-project. The Dangerfile contains a collection of home-grown...
Read more >
rollup.js
json file. If your package.json file also has a module field, ES-module-aware tools like Rollup and webpack 2+ will import ...
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