Skip to content
This repository has been archived by the owner. It is now read-only.

3.3.6: What are absolute file paths in package.json used for? #10393

Closed
jamesshore opened this issue Nov 14, 2015 · 25 comments

Comments

@jamesshore
Copy link

commented Nov 14, 2015

After upgrading to Node 5.0.0/npm 3.3.6, I noticed that npm now adds an _args and _where property to the package.json file. I check my node_modules directory into git, so I'm concerned that these absolute paths will cause problems when I check out the node_modules directory on other machines.

What are those entries used for, and will they cause problems when node_modules is moved to another location?

Here's an example package.json, resulting from npm install karma-commonjs. Note the _args and _where properties:

{
  "_args": [
    [
      "karma-commonjs@0.0.13",
      "/Users/jshore/Documents/Projects/weewikipaint"
    ]
  ],
  "_from": "karma-commonjs@0.0.13",
  "_id": "karma-commonjs@0.0.13",
  "_inCache": true,
  "_location": "/karma-commonjs",
  "_npmUser": {
    "email": "vojta.jina@gmail.com",
    "name": "vojtajina"
  },
  "_npmVersion": "1.4.4",
  "_phantomChildren": {},
  "_requested": {
    "name": "karma-commonjs",
    "raw": "karma-commonjs@0.0.13",
    "rawSpec": "0.0.13",
    "scope": null,
    "spec": "0.0.13",
    "type": "version"
  },
  "_requiredBy": [
    "#DEV:/"
  ],
  "_resolved": "https://registry.npmjs.org/karma-commonjs/-/karma-commonjs-0.0.13.tgz",
  "_shasum": "9b6c3feb7eed892d275c879e89ceb0c8accb0bb5",
  "_shrinkwrap": null,
  "_spec": "karma-commonjs@0.0.13",
  "_where": "/Users/jshore/Documents/Projects/weewikipaint",
  "author": {
    "email": "vojta.jina@gmail.com",
    "name": "Vojta Jina"
  },
  "bugs": {
    "url": "https://github.com/karma-runner/karma-commonjs/issues"
  },
  "contributors": [
    {
      "name": "Vojta Jina",
      "email": "vojta.jina@gmail.com"
    },
    {
      "name": "James Shore",
      "email": "jshore@jamesshore.com"
    },
    {
      "name": "Ben Drucker",
      "email": "bvdrucker@gmail.com"
    },
    {
      "name": "Marian Zagoruiko",
      "email": "marian@zagoruiko.gmail.com"
    }
  ],
  "dependencies": {},
  "description": "A Karma plugin. Test CommonJS modules.",
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-auto-release": "~0.0.3",
    "grunt-bump": "~0.0.11",
    "grunt-contrib-jshint": "~0.6.0",
    "grunt-karma": "~0.6.2",
    "grunt-npm": "~0.0.2"
  },
  "directories": {},
  "dist": {
    "shasum": "9b6c3feb7eed892d275c879e89ceb0c8accb0bb5",
    "tarball": "http://registry.npmjs.org/karma-commonjs/-/karma-commonjs-0.0.13.tgz"
  },
  "homepage": "https://github.com/karma-runner/karma-commonjs",
  "installable": true,
  "keywords": [
    "commonjs",
    "karma-plugin"
  ],
  "license": "MIT",
  "main": "lib/plugin.js",
  "maintainers": [
    {
      "name": "vojtajina",
      "email": "vojta.jina@gmail.com"
    }
  ],
  "name": "karma-commonjs",
  "optionalDependencies": {},
  "peerDependencies": {
    "karma": ">=0.9"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/karma-runner/karma-commonjs.git"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "version": "0.0.13"
}

@jamesshore jamesshore changed the title 3.3.6: What are absolute file paths in package.json for? 3.3.6: What are absolute file paths in package.json used for? Nov 14, 2015

@iarna iarna added the support label Dec 11, 2015

@iarna

This comment has been minimized.

Copy link
Contributor

commented Dec 11, 2015

They are just there to provide greater transparency as to what the installer was thinking at install time. At this time, the only _ properties used in future installs are _requiredBy if it contains #USER and _requested in some limited cases.

@iarna

This comment has been minimized.

Copy link
Contributor

commented Dec 11, 2015

And to directly address your concern, no, these will not impact moving the node_modules folder elsewhere– as explained above, these are sometimes used as hints to npm on future runs of the the npm installer, but are never required.

Does this answer your question?

@jamesshore

This comment has been minimized.

Copy link
Author

commented Dec 12, 2015

Yep, thank you!

@jamesshore jamesshore closed this Dec 12, 2015

@juanjoDiaz

This comment has been minimized.

Copy link

commented Jan 20, 2016

Is there any way of avoiding those?? If I'm packaging my app to be distributed (let say an electron/NW app) I definitely don't want my local paths included.

@mayeaux

This comment has been minimized.

Copy link

commented Mar 28, 2016

@juanjoDiaz Did you find a solution for this?

@juanjoDiaz

This comment has been minimized.

Copy link

commented Mar 28, 2016

Nope. Just manually (or using a script) removing those paths.

I still think that this is an issue that should be addressed by the npm team at some point.

@mayeaux

This comment has been minimized.

Copy link

commented Mar 28, 2016

Yeah I just brought it up in an issue here on NPM.

What does your process for removing them / using a script to remove them look like? Can you post the code? I am building out an NW.js that I want to distribute

@juanjoDiaz

This comment has been minimized.

Copy link

commented Apr 5, 2016

Hey Anthony! I'm really sorry. Totally miss this message.

I've published a little module with the code I use for this so you can use it if you want.

https://www.npmjs.com/package/removeNPMAbsolutePaths

@mayeaux

This comment has been minimized.

Copy link

commented Apr 5, 2016

Nice @juanjoDiaz, great work here! :)

@sanmai-NL

This comment has been minimized.

Copy link

commented Jul 5, 2016

I think was a bad decision to put these absolute paths in package.json. To log installation time info, write a log.

@mayeaux

This comment has been minimized.

Copy link

commented Jul 5, 2016

^ Personally agreed

@atypicalprogrammer

This comment has been minimized.

Copy link

commented Jul 20, 2016

Any updates?

@juanjoDiaz

This comment has been minimized.

Copy link

commented Jul 20, 2016

@atypicalprogrammer, this issue is closed so I wouldn't expect any fix for this.

@armoucar

This comment has been minimized.

Copy link

commented Sep 22, 2016

There could be at least an option to run npm without adding this.

@davidkethel

This comment has been minimized.

Copy link

commented Nov 22, 2016

@juanjoDiaz

This comment has been minimized.

Copy link

commented Nov 22, 2016

This is not fixed. And, since it's closed, I don't think it will be fixed.
In theory, those absolute paths are not used for anything so they shouldn't be creating trouble.
I recommend you give it a go to https://www.npmjs.com/package/removeNPMAbsolutePaths which basically removes the stuff that npm add automatically to the package.json of modules and see if that fixes your problem.

@stanleyxu2005

This comment has been minimized.

Copy link

commented Jun 22, 2017

Hope there is a switch to turn them off. Sometimes we need to commit node modules into private repo for some reason. Developer 1 checkouts project at c:/proj, and Developer 2 checkouts project at d:/proj There will be many diff about the absolute paths change. This is really annoying!

@monshi

This comment has been minimized.

Copy link

commented Aug 11, 2017

This issue is fixed in npm@5 but I'm still wondering how this issue was around for such a long time!

@stanleyxu2005

This comment has been minimized.

Copy link

commented Aug 12, 2017

@monshi I dont know whether my install command is correct or not, but there are still many redundant information in package.json. I'm using npm 5.0.3 by the way.

image

@monshi

This comment has been minimized.

Copy link

commented Aug 12, 2017

I agree and I'm not sure why something like "_where": "d:\\ij" is useful for install, but as far as I was concerned about the issue is fixed in v5, which was related to "_inCache": true causing npm install to fail with an untar read error.

@juanjoDiaz

This comment has been minimized.

Copy link

commented Aug 12, 2017

It is not fixed if it still contains _where": "d:\\ij

I think that it would be very useful if npm provides a list of fields that are not strictly necessary

@stanleyxu2005

This comment has been minimized.

Copy link

commented Aug 12, 2017

@juanjoDiaz @monshi Yeah, it becomes a very awkward fact that the only reason I use npm is to install and to upgrade yarn, which makes the node_modules dir more compact and easy to manage.

@Floo0S

This comment has been minimized.

Copy link

commented Jan 5, 2018

I had the same thought and do not understand why the npm team would like to keep that. I use yarn instead of npm now. Everything wonderful, no more private information in the files!

@sgronblo

This comment has been minimized.

Copy link

commented Jan 25, 2018

I agree this is awkward. This is something that shouldn't be there by default. It should ideally have been something you enable explicitly or at least have a way to disable this from being generated.

sgronblo pushed a commit to vaana-tech/cloudwatch-logs-to-papertrail that referenced this issue Feb 2, 2018
@alexeagle

This comment has been minimized.

Copy link

commented Feb 6, 2018

Another problem with this: it makes the installation non-deterministic. If using a build tool like Make or Bazel, the change in the package.json from one execution to another (eg. the CI machine has a different tmp folder) means that any build actions which depend on reading package.json (most of them) cannot be cache hits.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
You can’t perform that action at this time.