2017-03-02 49 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