0

I have the following package.json in a directory ~/dirA:

{
  "name": "dirA",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "vue": "^2.1.8"
  },
  "devDependencies": {
    "vue-loader": "^10.0.2"
  }
}

Then I cd to ~/dirB and run npm install ../dirA so that the node_modules directory gets created in dirB.

The problem is that it does not install the devDependencies. My NODE_ENV environment variable is not set.

I just get this output:

[~/dirB]$ npm install ../dirA
/home/tbeadle/dirB
`-- dirA@1.0.0
  `-- vue@2.1.8

npm WARN enoent ENOENT: no such file or directory, open '/home/tbeadle/dirB/package.json'
npm WARN dirB No description
npm WARN dirB No repository field.
npm WARN dirB No README data
npm WARN dirB No license field.

I can even use npm install --only=dev ../dirB and it continues to ignore the devDependencies I have defined in the package.json.

Any idea on how I can get these devDependencies installed?

Tommy
  • 245
  • 4
  • 11
  • if you are building for production devDependencies won't be installed, take a look at the [readme](https://github.com/npm/npm/blob/2e3776bf5676bc24fec6239a3420f377fe98acde/doc/files/package.json.md#devdependencies) edit: nah the docs suck, check out [this question](http://stackoverflow.com/questions/18875674/whats-the-difference-between-dependencies-devdependencies-and-peerdependencies) – wizebin Dec 31 '16 at 05:25

1 Answers1

0
npm install <directory>

does not do what you are trying to do. According to the docs here,

npm install :

Install a package that is sitting in a folder on the filesystem.

Also as the console warn suggests, the npm install needs to run where package.json is present. To install to dirA from dirB, do this:

cd dirB

mkdir -p ../dirA/node_modules

npm install --prefix path_to_folder_in_dirA

Check this stackoverflow question

Community
  • 1
  • 1
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103