NPM: After “npm link” module is not found

后端 未结 10 888
情深已故
情深已故 2021-02-11 11:31

I\'m developing two modules for NodeJS, first one named aligator and second one aligator-methods. Second one depends on first one to work. I\'m develop

相关标签:
10条回答
  • 2021-02-11 12:20

    Fix for my version of this issue; in npm v5.3.0, I removed node_modules from repo I was linking into another project.

    I found out that after npm v3 they try to put all node_modules dependencies into one node_modules directory (one in your project) to flatten the structure as much as possible (http://codetunnel.io/npm-5-changes-to-npm-link/).

    0 讨论(0)
  • 2021-02-11 12:26

    When using peerDependency

    I'm developing two packages, stejs, and stejs-loader. stejs-loader has stejs as a peerDependency. When I ran npm link stejs-loader and npm link stejs in my project I was getting an error that stejs-loader couldn't find stejs. I got it fixed by running npm link stejs in the directory of stejs-loader.

    0 讨论(0)
  • 2021-02-11 12:27

    My issue ended up being that repo A was using npm and repo B was using yarn, so I needed to run yarn link in repo B in order to pull it in via npm link package-name into repo A.

    0 讨论(0)
  • 2021-02-11 12:30

    What worked for me was to:

    1. Delete the node_modules in both the dependency and the consumer module.
    2. Run npm unlink --no-save [dependency-module]
    3. re-link with the 2-link commands as per npm-link

    Now I am able to fully test my unpublished module locally.

    Additionally, there is an npm pack command which can help you test your unpublished modules, although not quite as robust.

    npm-pack

    0 讨论(0)
提交回复
热议问题