思考実験室

日々のつれづれ

hoge配下にnpmでhogeモジュールをインストールしてはいけない

とりあえずReactをはじめてみようとのことで、以下のようなことをやってみた

$ mkdir react
$ cd react/
$ npm init -y

Wrote to /Users/username/react/package.json:

{
  "name": "react",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

で、次にreactをnpmよりinstallしようとしたら、ダメだった

$ npm install --save react


npm ERR! code ENOSELF
npm ERR! Refusing to install package with name "react" under a package
npm ERR! also called "react". Did you name your project the same
npm ERR! as the dependency you're installing?
npm ERR! 
npm ERR! For more information, see:
npm ERR!     <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>

Did you name your project the same as the dependency you're installing?
「あなたのプロジェクト名と同じ名前のモジュールをインストールしましたか?」とあります。
つまり、react 配下にreactはインストールできないんですね、というお話でした。