[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:
- Created 3 years ago
- Reactions:9
- Comments:8 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@guyonroche the published npm package is missing a few files, most notably
excel.js
, but alsoREADME_zh.md
and maybeindex.ts
. It would be great to include those and publish that as 4.0.1Also, how did you decide which files and folders to include? If it was manual, should we maybe use an npmignore file instead?
Also experiencing this… how did this get released with such a breaking issue?