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.

[BUG] A problem with package.json main entry path

See original GitHub issue

🐛 Bug Report

Lib version: 4.0.0 The error is :

Error: Cannot find module 'C:\Users\Nasreddine\Desktop\lab\clean-install\node_modules\exceljs\excel.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (internal/modules/cjs/loader.js:316:19)
    at Function.Module._findPath (internal/modules/cjs/loader.js:705:18)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:969:27)
    at Function.Module._load (internal/modules/cjs/loader.js:864:27)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (C:\Users\Nasreddine\Desktop\lab\clean-install\index.js:1:15)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32) {
  code: 'MODULE_NOT_FOUND',
  path: 'C:\\Users\\Nasreddine\\Desktop\\lab\\clean-install\\node_modules\\exceljs\\package.json',
  requestPath: 'exceljs'
}

Steps To Reproduce

I did a clean install of the exceljs and ran it this way

const Excel = require('exceljs');
const workbook = new Excel.Workbook();
const sheet = workbook.addWorksheet('My Sheet');
(async () => {
  await workbook.xlsx.writeFile('out.xlsx');
})();

The expected behaviour:

I expected the package would export a file in the root directory of the project with the name “out.xlsx”

Behaviour in previous version “3.10.0”

Works perfectly with the desired behaviour.

Possible solution (optional, but very helpful):

Change this line in package.json

...
135:    "main": "./excel.js",
...

To

...
135:   "main": "./lib/exceljs.nodejs.js",
...

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
alubbecommented, Jun 3, 2020

@guyonroche the published npm package is missing a few files, most notably excel.js, but also README_zh.md and maybe index.ts. It would be great to include those and publish that as 4.0.1

Also, how did you decide which files and folders to include? If it was manual, should we maybe use an npmignore file instead?

4reactions
JLuboffcommented, Jun 3, 2020

Also experiencing this… how did this get released with such a breaking issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

package.json - npm Docs
The main field is a module ID that is the primary entry point to your program. That is, if your package is named...
Read more >
npm error - verify that the package.json has a valid "main" entry
In my case, I was getting this error from my VS Code ESLint plugin output. However running the linter through the terminal was...
Read more >
package.json - Yarn
The two most important fields in your package.json are name and version , without them your package won't be able to install. The...
Read more >
CommonJS modules | Node.js v19.3.0 Documentation
json file present in the directory, or if the "main" entry is missing or cannot be resolved, then Node.js will attempt to load...
Read more >
How I solved and debugged my Webpack issue through trial ...
module.exports = { entry: { main: './src/index.js' }, output: { path: path.resolve(__dirname, ...
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