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.

npm install fails for a package added as dependency in another package

See original GitHub issue

I have 2 services-serviceA and serviceB. serviceA is added as a dev-dependency in serviceB

package.json of serviceB has

“devDependencies”: { “serverless-bundle”: “^4.0.1”, “serviceA”: “^0.1.0” }

Expected Behavior

npm install should install serverless-bundle and ignore serviceA

Current Behavior

npm install fails with error

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/serviceA - Not found
npm ERR! 404
npm ERR! 404  'serviceA@^0.1.0' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'serviceA'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
</p></details>
{
  "packages": ["lib/*", "services/*"],
  "version": "0.0.0.0",
  "useWorkspaces": true,
  "npmClient": "npm"
}

<details><summary>lerna-debug.log</summary><p>
<!-- browsers demand the next line be empty -->

```txt
<!-- If you have a `lerna-debug.log` available, please paste it here -->
<!-- Otherwise, feel free to delete this <details> block -->

Context

Your Environment

Executable Version
lerna --version VERSION
npm --version VERSION
yarn --version VERSION
node --version VERSION
OS Version
NAME VERSION

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13

github_iconTop GitHub Comments

1reaction
jamiehaywoodcommented, Feb 28, 2021

hi @s1mrankaur can you provide more details? It would be useful to see the package.json of serviceA.

0reactions
markdaschercommented, Oct 7, 2021

Not involved in this project at all, but as far as I can tell, this is by design. It’s more obvious once you know how lerna actually works, which is surprisingly hard information to find: https://github.com/lerna/lerna/issues/2447#issuecomment-608410145

lerna bootstrap is just calling npm install under the hood after removing local packages from the package.json.

In my case, I was trying to troubleshoot missing dependencies after an npx lerna bootstrap. Once I understood how lerna worked, I was able to mimic it by deleting the same local packages from package.json before running npm install.

There’s really no way npm install could possibly work without deleting the local packages from package.json first. npm would somehow have to know to skip the lerna-managed stuff. Maybe if lerna added something to package.json or package-lock.json, but I’m not sure what that would be.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NPM doesn't install module dependencies - Stack Overflow
I found out that two of the packages needed different versions of the dependency. I resolved the conflict, removed node_modules and after a...
Read more >
Dependency or package not found - DeployHQ
Troubleshooting missing package or dependency errors when using the DeployHQ build pipeline.
Read more >
npm-ci
Save installed packages to a package.json file as dependencies. When used with the npm rm command, removes the dependency from package.json . Will...
Read more >
NPM Dependency errors? Then You're doing it wrong. - Medium
0, then when you run NPM install, it will automatically upgrade it to 1.3.0 since you specify it as ^(caret) in package.json. The...
Read more >
Npm install error(fails) - M220JS - MongoDB
... npm install and it started to show errors , tried different methods like changing package.json dependencies to " * " , installing...
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