Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm using the wrong package.json file from a parent folder #5216

Closed
2 tasks done
krtek4 opened this issue Jul 25, 2022 · 1 comment
Closed
2 tasks done

[BUG] npm using the wrong package.json file from a parent folder #5216

krtek4 opened this issue Jul 25, 2022 · 1 comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@krtek4
Copy link

krtek4 commented Jul 25, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When trying to install packages using npm install or seeing the current directory using npm prefix, npm display a parent directory also containing a package.json file.

This seems to only happen with the exact package.json file I use for this project. I wasn't able to create a minimal reproductible folder structure.

Expected Behavior

npm uses the current directory as expected.

Steps To Reproduce

± pwd
/home/gilcrt/Repositories/CCI/cci-packages/projects/cci-utils
± ls -l package.json
-rw-r--r-- 1 gilcrt gilcrt 1.2K Jul 25 17:12 package.json
± npm prefix
/home/gilcrt/Repositories/CCI/cci-packages
± cat package.json

{
  "name": "@cci/utils",
  "version": "3.0.1",
  "description": "Internal package with various helpers that are routinely used in CCI Angular projects",
  "author": "Service Cantonal de l'Informatique, Centre de Compétence Internet, Canton du Valais",
  "license": "UNLICENSED",
  "contributors": [<redacted>],
  "scripts": {
    "typecheck": "tsc -p \"tsconfig.typecheck.json\"",
    "test": "ng test --pass-with-no-tests cci-utils",
    "lint": "ng lint cci-utils",
    "build": "ng build cci-utils",
    "version": "npm run lint && npm run test && ts-node --project ../../tsconfig.node.json ../../scripts/update-version.ts cci-utils && npm run build"
  },
  "publishConfig": {
    "directory": "../../dist/cci-utils",
    "registry": "https://nexus.vs.ch/repository/npm-private/"
  },
  "repository": {
    "type": "git",
    "url": "https://git.vs.ch/cci/packages.git",
    "directory": "projects/cci-utils"
  },
  "peerDependencies": {
    "@angular/common": ">=13.0.0",
    "rxjs": "6.6.7"
  },
  "dependencies": {
    "tslib": "^2.2.0",
    "type-fest": "0.16.0"
  },
  "gitHead": "ed1b5036653a84fd593d1d012c1deb0fb424664b"
}

I don't understand why the prefix isnt the current working directory as it should be.

Environment

; "user" config from /home/gilcrt/.npmrc
cafile = "/usr/local/share/ca-certificates/extra/Etat.Vs.pem"

; "project" config from /home/gilcrt/Repositories/CCI/cci-packages/.npmrc

@cci:registry = "https://nexus.vs.ch/repository/npm-private"
always-auth = true
email = "<redacted>"
strict-ssl = false

; node bin location = /usr/bin/node
; node version = v16.16.0
; npm local prefix = /home/gilcrt/Repositories/CCI/cci-packages
; npm version = 8.11.0
; cwd = /home/gilcrt/Repositories/CCI/cci-packages
; HOME = /home/gilcrt
; Run `npm config ls -l` to show all defaults.
@krtek4 krtek4 added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Jul 25, 2022
@fritzy
Copy link
Contributor

fritzy commented Jul 26, 2022

This could be happening if projects/cci-utils is a workspace of cci-packages. workspace is implicitely set, and prefix is set to the root workspace when running commands within a workspace.

I updated the docs.

If this is not what's happening, feel free to re-open this issue, indicating what is in the root package.json file.

@fritzy fritzy closed this as completed Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

2 participants