2017-01-10 7 views
0

node.jsを必要とする新しいプロジェクトを開始しようとしています。フォルダを作成した後、node_modulesを自分のプロジェクトフォルダに表示しようとしています。したがって、私はnpm initの後にpackage.jsonファイルに依存しない

npm init 

を使用し、その後、私はそれをインストールした後

npm install 

を使用し、私は私のnode_modulesフォルダが空であることに気づいたので、私はpackage.jsonをチェックアウト。私は依存関係がないことを認識しました

この問題を解決する方法はありますか?

+0

NPMはpackage_you_need --save-devをインストールしてください。 [doco](https://docs.npmjs.com/cli/install)を参照してください。 – lloyd

+0

まだパッケージをインストールしていない場合は、npm install express -saveを実行すると、node_modulesの中に明示的に表示されます –

答えて

1

あなたはNPMは、あなたがCLIで以下のような値が入力されている場合がありますinitがないとき:

{ 
    "name": "test-app", 
    "version": "1.0.0", 
    "description": "This is a test app", 
    "main": "app.js", 
    "scripts": { 
    "test": "npm test" 
    }, 
    "author": "Sagar Gopale", 
    "license": "ISC" 
} 

name: (testApp) 
Sorry, name can no longer contain capital letters. 
name: (testApp) testApp 
Sorry, name can no longer contain capital letters. 
name: (testApp) test-app 
version: (1.0.0) 
description: This is a test app 
entry point: (index.js) app.js 
test command: npm test 
git repository: 
keywords: 
author: Sagar Gopale 
license: (ISC) 
About to write to /home/sagargopale/Projects/testApp/package.json: 

を次に上記の構成で、次のように作成したpackage.jsonがあります依存関係ブロックをpackage.jsonに追加する依存関係をインストールします。例えば、私は

npm install express --save 

を行うならば、package.jsonは以下のようになります。

{ 
    "name": "test-app", 
    "version": "1.0.0", 
    "description": "This is a test app", 
    "main": "app.js", 
    "scripts": { 
    "test": "npm test" 
    }, 
    "author": "Sagar Gopale", 
    "license": "ISC", 
    "dependencies": { 
    "express": "^4.14.0" 
    } 
} 
関連する問題