Resolved: Error [ERR_MODULE_NOT_FOUND]: Cannot find package ‘octokit’ imported

In this post, we will see how to resolve Error [ERR_MODULE_NOT_FOUND]: Cannot find package ‘octokit’ imported

Question:

I am trying to run this javascript:
myrepo/src/sample.js
with this package.json file:
myrepo/package.json
But get this error:
So seems the script is not aware of the node_modules folder that contains the octokit packages?

Best Answer:

It looks like you’re looking for the @octokit/core module instead of simply octokit (note: they are two distinct NPM packages, but you only have @octokit/core installed). From the README:

Install with npm install @octokit/core const { Octokit } = require("@octokit/core"); // or: import { Octokit } from "@octokit/core";


So, try changing this line in your code
to
If you are in fact looking for the octokit package, then you’ll need run npm install octokit to install that package. You’ll probably want to run npm remove @octokit/core to remove the other (more minimal) package too.

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com