Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

.npmrc prefix config is not respected #6358

Closed
jblandry opened this issue Sep 30, 2014 · 7 comments
Closed

.npmrc prefix config is not respected #6358

jblandry opened this issue Sep 30, 2014 · 7 comments
Labels

Comments

@jblandry
Copy link

[ osx 10.9.5 / node v0.10.32 / npm v2.0.2 ]

In my project I have a .npmrc file containing

prefix = ./dependencies

When I run an npm install it creates a folder dependencies but puts the node_modules in the project's root.

It works correctly if I run

npm install [package] --prefix ./dependencies
@othiym23
Copy link
Contributor

That is because prefix, and only prefix, behaves differently when used as a command-line parameter as (somewhat obscurely) described in the docs:

prefix

  • Default: see npm-folders(5)
  • Type: path

The location to install global items. If set on the command line, then it forces non-global commands to run in the specified folder.

The way you've set the prefix in config can't work (because it's a relative path), and wouldn't do what you want it to even if it did (as you've seen).

@jblandry
Copy link
Author

jblandry commented Oct 1, 2014

So there is no way of creating the node_modules in another directory than the current one while using npm install with a package.json file?

@aredridel
Copy link
Contributor

What's your use-case?

@jblandry
Copy link
Author

jblandry commented Oct 1, 2014

I want all my config files (including package.json) in my root directory but I want also want the node_modules folder under a dependencies folder.

- .jshintrc
- bower.json
- package.json
- [assets]
- [dependencies]
   - [bower]
   - [node_modules] (ideally here)
- [scripts]

@othiym23
Copy link
Contributor

othiym23 commented Oct 1, 2014

npm's primary job is to read dependencies from a package.json file, and then install them into a node_modules directory at that same location. This is part of its Node heritage, and while we may make it more flexible in the future for browser-centric workflows, that behavior can't be changed for now.

@jblandry
Copy link
Author

jblandry commented Oct 2, 2014

Ok not a problem thanks 👍

@yordivad
Copy link

yordivad commented May 25, 2016

These is a schaisser, these is causing a lot of the problems with msbuild, becuase msbuild don't support more that 256 characters in the path, also continues integration create some problems, when i download the project i also need to download all packages, it is not in a central folder as nuget.
The tools of analysis code spent a lot of the time because node modules in the project root.

how is not going possible to change it?. it is insane

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants