[BUG] Project name was being added to dependencies automatically
Is there an existing issue for this?
- [X] I have searched the existing issues
This issue exists in the latest npm version
- [X] I am using the latest npm
Current Behavior
Hi,
i have a serverlss project whichh run on node 20. every time I open the protect a line with project name and "file:" was being added automatically.
tried removing the node-modules and package-lock file and doing a fresh install but this does not work. and also tried updating now to 22 and npm as well.
does anyone know the issue here?
Expected Behavior
{ "name": "example", "version": "1.0.0", "main": "index.js", "scripts": { "compile": "tsc", "start": "nodemon --exec "npm run offline" -e js,mjs,json,yml,yaml", "test": "jest", "test-coverage": "jest --coverage", "integration": "echo "no test found" ", "deploy-dev": "sls deploy -s dev", "offline": "serverless offline --httpPort 3007 --lambdaPort 3017" }, "license": "ISC", "devDependencies": { "@types/aws-lambda": "^8.10.142", "eslint": "^9.7.0", "eslint-plugin-react": "^7.35.0", "jest": "^29.7.0", "jest-teamcity": "^1.12.0", "nodemon": "^3.1.4", "offline": "^0.0.1", "serverless": "^3.39.0", "serverless-iam-roles-per-function": "^3.2.0", "serverless-offline": "^13.6.0", "serverless-plugin-common-excludes": "^4.0.0", "serverless-plugin-include-dependencies": "^6.1.1", "serverless-plugin-log-retention": "^2.0.0", "serverless-plugin-typescript": "^2.1.5", "typescript": "^5.5.4" }, "dependencies": { "aws-sdk": "^2.1663.0", "axios": "^1.7.4", "joi": "^17.13.3", "mssql": "^11.0.1", "example": "file:", "serverless-plugin-resource-tagging": "^1.2.0" } }
"example": "file:", --> This line was being added automatically.
Steps To Reproduce
- In this environment...
- With this config...
- Run '...'
- See error...
Environment
- npm: 10.8.2
- Node.js: 22.7.0
- OS Name: Windows 11
- System Model Name: 64 bit intel PS C:\Users****\Desktop\Projects\prerp> npm config ls ; "user" config from C:\Users\knaresh.npmrc
legacy-peer-deps = true
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v22.7.0
; npm local prefix = C:\Users*\Desktop\Projects\prerp
; npm version = 10.8.2
; cwd = C:\Users*\Desktop\Projects\prerp
; HOME = C:\Users****
; Run npm config ls -l to show all defaults.
64-bit
@naresh1054 Please provide steps to reproduce to understand for which situation it's happening.
@milaninfy I had a project a long time back, when I came back and tried starting it using the command npm start it started adding a new line in the dependencies section of package.json with key as project name and value as "file:". I am facing the same issue in all of my projects. I tried deleting the lock file along with node_modules but still, the issue was not resolved.
you mentioned that all your project is having this issue in the description, is it happening when you do npm install or when you do script run like npm run start ?
It's happening in both scenarios: whether I remove the line from package.json and then run npm install, or simply remove the line from package.json without running any commands, the line gets automatically added back into the file.
@naresh1054 Issue seems like unrelated to npm cli, but to be sure Could you please check the same with different version of npm? e.g. if you are using 10.8.2, try with 10.7.0 of some other lower version if it's the same.
@naresh1054 , if you are using VS code and installed the extension Red Hat Dependency Analytics disable it for now , for my case it was the problem with their last version (V 0.9.5 )
Closing due to age. If this is still a problem please feel free to reopen this issue, or create a new issue w/ steps to reproduce.
yeah, I have this extension for my vs code. disabling it solved the issue. Thanks @seifeddine-brahem
@naresh1054 , if you are using VS code and installed the extension Red Hat Dependency Analytics disable it for now , for my case it was the problem with their last version (V 0.9.5 )
This worked for me. Thanks
@naresh1054 , if you are using VS code and installed the extension Red Hat Dependency Analytics disable it for now , for my case it was the problem with their last version (V 0.9.5 )
Worked for me too. Thank you so much.
I resolved it by uninstalling the Red Hat Dependency Analytics extension. Thank you.
@naresh1054 , if you are using VS code and installed the extension Red Hat Dependency Analytics disable it for now , for my case it was the problem with their last version (V 0.9.5 )
This did the trick for me!
This is happening to me with npm install --prefix on Windowsn (Git bash) with npm 10.9.3.
The same constructiuon works well on WSL as well as OSX.