Custom module npm package experiencing missing files issue

Introducing a new npm package called leon-theme. You can find it on npm at this link: https://www.npmjs.com/package/leon-theme

For the source code, head over to Github here: https://github.com/leongaban/leon-theme

After running npm run build locally in the custom package, the dist folder is generated correctly. However, upon publishing, all files except for README and package.json seem to be missing.

This issue results in not being able to import the new package into a fresh react app as the module cannot be found.

Click here for more details

tsconfig Configuration:

{
  "compilerOptions": {
    "module": "ES6",
    "target": "es2016",
    "lib": ["ES2020", "DOM"],
    "jsx": "react",
    "declaration": true,
    "declarationDir": "types",
    "sourceMap": true,
    "allowSyntheticDefaultImports": true,
    "noEmit": false,
    "outDir": "./dist/lib/es6",
    "moduleResolution": "node"
  },
  "include": ["src/**/*"]
}

Main package.json Configuration:

{
  "name": "leon-theme",
  "version": "1.0.0",
  "module": "lib/es6/index.js",
  "description": "A simple React style & component library",
  "scripts": {
    "build": "rm -rf dist/lib && tsc --build"
  },
  "author": "Leon Gaban",
  "license": "ISC",
  "dependencies": {
    "react": "^18.2.0"
  },
  "devDependencies": {
    "@types/react": "^18.2.22",
    "jest-environment-jsdom": "^29.7.0",
    "tslib": "^2.6.2",
    "typescript": "^5.2.2"
  },
  "files": [
    "dist"
  ],
  "types": "dist/index/.d.ts"
}

Package.json Configuration within the 'dist' Folder:

{
  "name": "leon-theme",
  "version": "0.0.6",
  "module": "lib/es6/index.js",
  "description": "A simple React style & component library",
  "homepage": "https://github.com/leongaban/leon-theme",
  "bugs": {
    "url": "https://github.com/leongaban/leon-theme/issues"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/leongaban/leon-theme.git"
  },
  "keywords": [
    "javascript",
    "theme",
    "buttons",
    "leon"
  ],
  "scripts": {
    "build": "rm -rf dist/lib && tsc --build"
  },
  "author": "Leon Gaban",
  "license": "ISC",
  "dependencies": {
    "react": "^18.2.0"
  },
  "devDependencies": {
    "@types/react": "^18.2.22",
    "jest-environment-jsdom": "^29.7.0",
    "tslib": "^2.6.2",
    "typescript": "^5.2.2"
  },
  "files": [
    "dist"
  ],
  "types": "dist/index/.d.ts"
}

https://i.sstatic.net/CSq3y.png

https://i.sstatic.net/GQcAR.png

Answer №1

The issue lies within the dist/package.json file, which appears to be a streamlined version of the package.json. The same goes for README.md. These files are not necessary in the dist folder as they will be included automatically. For more information, check here.

To resolve the problem, simply remove these two files.

This problem is related to npm rather than npmjs.org specifically. You can verify the changes by running npm pack, which creates a TAR file (leon-theme-1.0.0.tgz) containing the package that would be published. You can examine this file using 7-zip or view the list of included files from the command output.

After deleting dist/package.json and dist/README.md, the resulting output shows the included files:

PS \repos\leon-theme> npm pack
npm notice 
npm notice package: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cca0a9a3a2e1b8a4a9a1a98cfde2fce2fc">[email protected]</a>
npm notice === Tarball Contents ===
npm notice 226B dist/lib/es6/components/Button/Button.js
npm notice 69B  dist/lib/es6/components/Button/index.js
npm notice 131B dist/lib/es6/components/index.js
npm notice 72B  dist/lib/es6/components/LeonTheme/index.js
npm notice 63B  dist/lib/es6/index.js
npm notice 305B dist/lib/es6/components/LeonTheme/LeonTheme.js
npm notice 518B package.json
npm notice 327B dist/lib/es6/components/Button/Button.js.map
npm notice 171B dist/lib/es6/components/Button/index.js.map
npm notice 222B dist/lib/es6/components/index.js.map
npm notice 174B dist/lib/es6/components/LeonTheme/index.js.map
npm notice 127B dist/lib/es6/index.js.map
npm notice 387B dist/lib/es6/components/LeonTheme/LeonTheme.js.map
npm notice 184B README.md
npm notice === Tarball Details ===
npm notice name:          leon-theme
npm notice version:       1.0.0
npm notice filename:      leon-theme-1.0.0.tgz
npm notice package size:  1.4 kB
npm notice unpacked size: 3.0 kB
npm notice shasum:        8e22b9a71680a31c72bbc813815dc30249b49f1b
npm notice integrity:     sha512-Nj92cJ+JOybD/[...]Hse0hWLqWWuFA==
npm notice total files:   14
npm notice
leon-theme-1.0.0.tgz

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

VS Code failing to detect Angular, inundated with errors despite successful compilation

Having some issues with loading my angular project in vscode. It used to work fine, but suddenly I'm getting errors throughout the project. I have all the necessary extensions and Angular installed. https://i.stack.imgur.com/qQqso.png Tried troubles ...

What could be causing my dropdown menu to not appear when clicked?

I am trying to implement the functionality shown in the image. When the Settings button is clicked, a window should open allowing the user to navigate to their desired option. However, I am facing an issue where nothing happens when the button is clicked. ...

Combining JavaScript objects within an array that share a common key

Can you provide an efficient way to combine array values from JavaScript objects that have a common key? How would you rearrange the contents of the array into the format of output? In this scenario, all value keys (whether single value or array) should b ...

Tips for implementing WebSockets in a NativeScript application

Is there anyone who can provide guidance on utilizing WebSockets in NativeScript? I am working with VueJS in NativeScript and attempting to retrieve data using ws. Any assistance on this matter would be greatly appreciated. Thank you ...

Executing a conditional onClick function when the page loads

I have implemented a php-based authorization system that loads different authorization levels into a JavaScript variable. My goal is to disable certain onclick events based on the user's authorization level. I've come up with the following code ...

Difficulty understanding D3 Angular: color fill remains unchanged

While developing an angular application with D3 JS, I encountered an issue with changing the fill color of an SVG. Upon reviewing the code, I noticed that I created one SVG and attempted to insert another one from a vendor: function link (scope, element, ...

Verification of radio selections

I have successfully implemented validation for the radio button. Now, I would like to add an alert box that asks "Are you sure you want to pick 'x'?" before proceeding with the code. If the user clicks cancel, they should return to the webpage. B ...

When Vue-router is built for production, the hashbang is not removed

I recently made a change to my Vue-router configuration by adding mode:'history' in the index file: export default new Router({ mode: 'history', routes: [ { path: '/', name: 'Daksh', compon ...

Steps for creating a herringbone design on an HTML canvas

Seeking Help to Create Herringbone Pattern Filled with Images on Canvas I am a beginner in canvas 2d drawing and need assistance with drawing mixed tiles in a cross pattern (Herringbone). var canvas = this.__canvas = new fabric.Canvas('canvas' ...

Troubleshooting Compatibility Issues: JavaScript Function Works in Chrome but not in Internet

After collaborating with fellow coders to develop info boxes using HTML, CSS, and JavaScript, I have come across an issue with the hover functionality not working properly in Internet Explorer. Interestingly, everything functions flawlessly on Google Chrom ...

The HTML5 range input is consistently defaulting to the minimum value and is not triggering the onChange event for text input

My goal is to implement a feature where an input type text is used along with an input type range with three specific use cases: 1. Default case: When the page loads, the slider should point to the value specified in the text input field. 2. When a user e ...

Track and maintain the active status of the clicked article using jQuery

I'm encountering an issue with jQuery where the parent ul li does not open as expected. Below is the structure of my HTML: <div> <ul> <li class="has-sub"> <a href="#">1</a> <ul> &l ...

Limiting image size in react-dropzone

I am currently utilizing react-dropzone for image uploads within my application. The functionality is working smoothly, including the validation for image size. However, I am facing an issue with checking the dimensions of the uploaded image. I am looking ...

Best practices for managing and utilizing ARCHIVE within CRAN-esque repositories

I am interested in creating my own repository similar to CRAN for my R packages. I have been exploring the use of package miniCran, but I also want to: Maintain and organize all previous versions (both source and binaries) as an Archive, allowing me to e ...

Encountering a TypeError in Mongoose: Unable to access properties of undefined while trying to read 'find'

Encountering an issue with the error message, TypeError: Cannot read properties of undefined (reading 'find'), specifically pointing to this block of code: app.get('/Organizations', (req,res) => { Organizations.find({}).then((organiz ...

Encountering a reference error while attempting to troubleshoot streamline.js generated JavaScript code

After successfully setting up streamline.js and generating code using _node --standalone -c stest._js, I encountered an issue. The generated code was not readable and debugging it in tools like Chrome's developer console seemed impossible. However, I ...

Searching for the object that occurs an uneven number of times

Currently, I am tackling a challenge on Codewars that requires identifying the element in an array that occurs an odd number of times. The current solution I have successfully passes 3 out of 6 tests. function findOdd(A) { //happy coding! let odd = &qu ...

Image not displayed after uploading to presigned AWS S3 URL in React Native

I've been attempting to upload an image to AWS S3 in my React Native app (expo managed workflow) but I keep encountering the issue of the file being empty. Strangely, there are no errors thrown during the process. Even after trying to use the Uppy AWS ...

Is it possible to use HTML text as a CSS selector with JavaScript?

I've been searching for a solution to this issue but haven't found anything that works for me. Check out this code on jsfiddle. Person1 and Person2 both have class="from" and the CSS selector is .from so it applies to both. However, I want it ...

Store the beginning and ending times in a MySQL database using Sequelize and Node.js

I am currently developing a project management application where I need to keep track of the start and stop time for user work. To achieve this, I have implemented two buttons in the UI - START and STOP. When a user clicks the START button, the following ...