2017-03-02 50 views
0

我剛剛從tutorialspoint(TP)開始學習NodeJs。使用節點Js中的npm init創建包的錯誤

當我想正是他們在this link說,

也就是說,創建一個包

C:\Program Files (x86)\nodejs>npm init 
This utility will walk you through creating a package.json file. 
It only covers the most common items, and tries to guess sane defaults. 

See `npm help json` for definitive documentation on these fields 
and exactly what they do. 

Use `npm install <pkg> --save` afterwards to install a package and 
save it as a dependency in the package.json file. 

Press ^C at any time to quit. 
name: (nodejs) VirdWAitJS 
version: (1.0.0) 2.0.1 
description: VirdWAitJS is an Open Source JavaScript Library meant for DOM Querying 
entry point: (index.js) virdwaitjs.js 
test command: hello world 
git repository: https://www.github.com/virdwait/virdwaitJs 
keywords: virdwait, virdwaitJS, DOM Query, VDJS, VD 
author: SAGAR V 
license: (ISC) MIT 
About to write to C:\Program Files (x86)\nodejs\package.json: 

{ 
    "name": "VirdWAitJS", 
    "version": "2.0.1", 
    "description": "VirdWAitJS is an Open Source JavaScript Library meant for DOM Querying", 
    "main": "virdwaitjs.js", 
    "dependencies": { 
    "npm": "^2.7.4" 
    }, 
    "devDependencies": {}, 
    "scripts": { 
    "test": "hello world" 
    }, 
    "repository": { 
    "type": "git", 
    "url": "https://www.github.com/virdwait/virdwaitJs" 
    }, 
    "keywords": [ 
    "virdwait", 
    "virdwaitJS", 
    "DOM", 
    "Query", 
    "VDJS", 
    "VD" 
    ], 
    "author": "SAGAR V", 
    "license": "MIT" 
} 
Is this ok? (yes) 

當我按下回車鍵,我收到以下錯誤。

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files (x86)\nodejs\\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "init"
npm ERR! node v0.12.2
npm ERR! npm v2.7.4
npm ERR! path C:\Program Files (x86)\nodejs\package.json
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! Error: EPERM, open 'C:\Program Files (x86)\nodejs\package.json'
npm ERR! at Error (native)
npm ERR! { [Error: EPERM, open 'C:\Program Files (x86)\nodejs\package.json']
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! path: 'C:\Program Files (x86)\nodejs\package.json' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files (x86)\nodejs\\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "init" npm ERR! node v0.12.2
npm ERR! npm v2.7.4
npm ERR! Uncaught, unspecified "error" event.
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues
npm ERR! Please include the following file with any support request:
npm ERR! C:\Program Files (x86)\nodejs\npm-debug.log

+2

您正嘗試在系統文件夾(由節點使用)中初始化npm軟件包。嘗試在它內部創建自己的工作文件夾和NPM init,如C:/ Work –

+0

您應該在您的主目錄中的文件夾中執行它 –

+0

感謝@JonathanMuller,它現在正在工作。 –

回答

1

您正在試圖建立一個系統文件夾 C:\Program Files (x86)\nodejs在您需要管理員密碼中的一個項目。

你可以以管理員身份打開你的cmd,然後你就可以在那裏爲你的項目打init