我刚开始从tutorialspoint(TP)学习NodeJs。
当我完全按照他们在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)
当我按下Enter按钮时,我收到以下错误。
npm ERR! Windows_NT 6.3.9600
错误的ERR! argv&#34; C:\ Program Files(x86)\ nodejs \\ node.exe&#34; &#34; C:\ Program Files(x86)\ nodejs \ node_modules \ npm \ bin \ npm-cli.js&#34; &#34;初始化&#34;
错误的ERR!节点v0.12.2
错误的ERR! npm v2.7.4
错误的ERR!路径C:\ Program Files(x86)\ nodejs \ package.json
错误的ERR!代码EPERM
错误的ERR! errno -4048
错误的ERR!错误:EPERM,打开&#39; C:\ Program Files(x86)\ nodejs \ package.json&#39;
错误的ERR!在错误(本机)
错误的ERR! {[错误:EPERM,打开&#39; C:\ Program Files(x86)\ nodejs \ package.json&#39;]
错误的ERR!错误:-4048,
错误的ERR!代码:&#39; EPERM&#39;,
错误的ERR!路径:&#39; C:\ Program Files(x86)\ nodejs \ package.json&#39; }
npm ERR!
错误的ERR!请尝试以root / Administrator方式再次运行此命令 错误的ERR! Windows_NT 6.3.9600
错误的ERR! argv&#34; C:\ Program Files(x86)\ nodejs \\ node.exe&#34; &#34; C:\ Program Files(x86)\ nodejs \ node_modules \ npm \ bin \ npm-cli.js&#34; &#34;初始化&#34; 错误的ERR!节点v0.12.2
错误的ERR! npm v2.7.4
错误的ERR!未知,未指明&#34;错误&#34;事件。
npm ERR!
错误的ERR!如果您需要帮助,可以在以下位置报告此错误:
错误的ERR! https://github.com/npm/npm/issues
错误的ERR!请在支持请求中包含以下文件:
错误的ERR! C:\ Program Files(x86)\ nodejs \ npm-debug.log
答案 0 :(得分:2)
您正在尝试在系统文件夹中创建项目
C:\Program Files (x86)\nodejs
您需要管理员密码。
您可以以管理员身份打开cmd,然后就可以在那里init
开展项目。
答案 1 :(得分:0)
同样地,在其他Unix平台上,如Mac,Linux,我需要使用'sudo'运行命令 - 管理权限为sudo npm init -y
以清除所有构建错误。