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.

Change devDependency to dependency

See original GitHub issue

You have d3-scale as a devDependency for nivo legends https://github.com/plouc/nivo/blob/master/packages/legends/package.json#L27

When we try to run your basic “hello world” examples we got:

Cannot find module 'd3-scale' from '../../node_modules/@nivo/legends/dist/nivo-legends.cjs.js'

    Require stack:
      /my-project/node_modules/@nivo/legends/dist/nivo-legends.cjs.js
      /my-project/node_modules/@nivo/line/dist/nivo-line.cjs.js

This should be moved to dependency or added as a peerDependency (preferably the former), otherwise it requires the user of Nivo to debug this. Naively one may try to install d3-scale in their package.json which will cause even more issues since the latest major version of said package is relying on experimental node features which will throw nonsensical errors taking the user further down the rabbit hole.

I believe this one small fix will greatly improve the DX for this library.

The code you publish in your dist for legends does a require("d3-scale") so this is not a devDependency.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
netzwergcommented, Aug 15, 2022

If using Yarn 2/3 berry you can add this temporary workaround to .yarnrc.yml which clears up the error (don’t forget to rerun yarn install after adding it):

# .yarnrc.yml

...

packageExtensions:
    '@nivo/legends@*':
        dependencies:
            'd3-scale': '*'
            '@nivo/colors': '*'
...

This only worked for me if declared as peerDependencies (possibly because I had both of them as dependencies in my package.json already):

...
 packageExtensions:
     '@nivo/legends@*':
         peerDependencies:
             'd3-scale': '*'
             '@nivo/colors': '*'
 ...
2reactions
davidcalhouncommented, Jun 13, 2022

Bump

Read more comments on GitHub >

github_iconTop Results From Across the Web

Move a module from devDependencies to dependencies in ...
So, if you need to switch a dependency from devDependencies to dependecies you can go to your package.json and move manually with no...
Read more >
Adding dependencies to a package.json file - npm Docs
To add dependencies and devDependencies to a package.json file from the command line, you can install them in the root directory of your...
Read more >
Installing Dev Dependencies with npm: Beginners' Guide
For npm users, the below command will help to add devDependencies in the project: [Replace 'dev dependencies' with the module you're installing.]
Read more >
Moving package form devDependencies to dependencies ...
lock, if I move the package from "devDependencies" to "dependencies" and rerun yarn install, the lock file does not change. Subsequently the ...
Read more >
Managing dependencies | Yarn
It will also update your yarn.lock to reflect the change. ... yarn add --dev to add to devDependencies; yarn add --peer to add...
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