私はMacOSX 10.7.5を使用しており、Gruntを使用していくつかのjsファイルを連結し、それらを縮小しています。ここで、cssファイルも縮小したいと思います。gruntは機能を提供しないので、そのためのgruntプラグインをインストールしたかったのです。指示に従って、プロジェクトのルートフォルダーにCDを挿入し、npmを使用してプラグインをインストールする必要があります。だから私は次のことをしました:
cd <PROJECT_ROOT>
npm install grunt-contrib-css
プラグインの手順は次のとおりです。https : //npmjs.org/package/grunt-contrib-mincss grunt.jsファイルを開いて、追加しました
grunt.loadNpmTasks('grunt-contrib-mincss');
しかし、私がうなり声を上げようとすると、私はただ得ます
Local Npm module "grunt-contrib-mincss" not found. Is it installed?
<WARN> Task "mincss" not found. Use --force to continue. </WARN>
インストールは問題なく機能し、npmlsはモジュールを一覧表示します。
私が間違ったことをしたアイデアはありますか?どうもありがとう!
更新しました
私がそのようなプロジェクトにCDを入れるとき
cd ~/Sites/path/to/project
プラグインをインストールします
sudo npm install grunt-contrib-mincss
モジュールは実際ににインストールされています
~/node_modules/grunt-contrib-mincss
ファイルをプロジェクトのルートディレクトリ(これは機能します)にハードコピーすることはできますが、それはちょっと奇妙なことではありませんか?
UPDATE 2 ノードを更新して、再試行しました。以下はコンソール出力です。
me:~ Fritz$ node -v
v0.8.10
me:~ Fritz$ npm -v
1.1.62
me:~ Fritz$ mkdir ./Sites/npm-test
me:~ Fritz$ cd ./Sites/npm-test/
me:npm-test Fritz$ sudo npm install grunt-contrib-mincss
Password:
npm http GET https://registry.npmjs.org/grunt-contrib-mincss
npm http 304 https://registry.npmjs.org/grunt-contrib-mincss
npm http GET https://registry.npmjs.org/gzip-js
npm http GET https://registry.npmjs.org/clean-css
npm http GET https://registry.npmjs.org/grunt-contrib-lib
npm http 304 https://registry.npmjs.org/gzip-js
npm http 304 https://registry.npmjs.org/clean-css
npm http 304 https://registry.npmjs.org/grunt-contrib-lib
npm http GET https://registry.npmjs.org/crc32
npm http GET https://registry.npmjs.org/deflate-js
npm http GET https://registry.npmjs.org/optimist
npm http 304 https://registry.npmjs.org/deflate-js
npm http 304 https://registry.npmjs.org/crc32
npm http 304 https://registry.npmjs.org/optimist
npm http GET https://registry.npmjs.org/wordwrap
npm http 304 https://registry.npmjs.org/wordwrap
grunt-contrib-mincss@0.3.0 ../../node_modules/grunt-contrib-mincss
├── grunt-contrib-lib@0.3.0
├── gzip-js@0.3.1 (crc32@0.2.2, deflate-js@0.2.2)
└── clean-css@0.4.2 (optimist@0.3.4)
プラグインが外部にインストールされているのはなぜですか?または、それがインストールされている実際の場所を定義する方法はありますか?