2

I wrote this npm module, react-heartbeat, using nwb. When I install this module in a new project, npm i react-heartbeat, just after running npm init it takes less than 2 seconds and only installs 1 package. When I install this module, again npm i react-heartbeat, after creating a project with create-react-app, it takes nearly 3 minutes, adds 420 packages, removes 218 packages and updates 1257 packages.

What am I doing wrong?

My npm module is very simple, just 1 React component. It has no dependencies in the package.json file. The following peer dependencies and dev dependencies that were created when nwb set the project up.

"peerDependencies": {
  "react": "16.x"
},
"devDependencies": {
  "@types/mocha": "^5.2.5",
  "nwb": "^0.23.0",
  "react": "^16.5.2",
  "react-dom": "^16.5.2"
},

I followed the instructions from nwb's documentation to prepare my module for publishing (npm run build) and to publish my module (npm publish). The proper folders are white-listed in my package.json:

"files": [
  "es",
  "lib",
  "umd"
],

I ran npm publish --dry-run and confirmed that only the following 7 files are included in my project:

package.json
README.md
es/index.js
lib/index.js
umd/react-heartbeat.js
umd/react-heartbeat.min.js
umd/react-heartbeat.min.js.map

I am wondering if the problem is in the peer or dev dependencies, but I am not sure how to fix this.

Here is the source code for react-heartbeat. It can be found here on npm.

  • I just tried installing `react-heartbeat` on a container on [Coder](https://coder.com) after creating a project using `create-react-app` and it only installed 1 package. So now I am wondering if the problem is with the Linux laptop I use to develop. Any suggestions on how to begin to troubleshoot this would be appreciated. – Scott Price Oct 18 '18 at 15:35

1 Answers1

1

create-react-app is supposed to install it's dependencies but maybe it failed. Every time you run npm i it will install missing dependencies from package.json.

Make sure dependencies are installed before installing yours by running npm i and check nothing new.

Gabriel Bleu
  • 9,703
  • 2
  • 30
  • 43
  • That does seem to be the problem. When I ran `npm i` right after running `create-react-app` it installed 418 packages. Then I installed my mode module, and it only installed 1 package. Now I have to figure out why this is happening. – Scott Price Oct 19 '18 at 12:51