0

我尝试从名为“联系人”的目录下的 package.json 文件中安装一堆文件。但是,我收到以下错误:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\nodejs\\\\node.exe',
1 verbose cli   'C:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   '-d' ]
2 info using npm@1.3.2
3 info using node@v0.10.13
4 verbose node symlink C:\nodejs\\node.exe
5 error install Couldn't read dependencies
6 error Error: Invalid name: "angular-$resource-example"
6 error     at ensureValidName (C:\nodejs\node_modules\npm\node_modules\read-package-json\node_modules\normalize-package-data\lib\fixer.js:281:15)
6 error     at Object.module.exports.fixNameField (C:\nodejs\node_modules\npm\node_modules\read-package-json\node_modules\normalize-package-data\lib\fixer.js:196:5)
6 error     at C:\nodejs\node_modules\npm\node_modules\read-package-json\node_modules\normalize-package-data\lib\normalize.js:29:38
6 error     at Array.forEach (native)
6 error     at normalize (C:\nodejs\node_modules\npm\node_modules\read-package-json\node_modules\normalize-package-data\lib\normalize.js:28:15)
6 error     at final (C:\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:310:33)
6 error     at then (C:\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:124:33)
6 error     at C:\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:234:40
6 error     at fs.js:266:14
6 error     at Object.oncomplete (fs.js:107:15)
7 error If you need help, you may report this log at:
7 error     <http://github.com/isaacs/npm/issues>
7 error or email it to:
7 error     <npm-@googlegroups.com>
8 error System Windows_NT 6.2.9200
9 error command "C:\\nodejs\\\\node.exe" "C:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-d"
10 error cwd C:\Users\Nafiul Islam\Desktop\Contacts
11 error node -v v0.10.13
12 error npm -v 1.3.2
13 verbose exit [ 1, true ]

以下是 package.json 文件:

{
  "name": "angular-$resource-example",
  "version": "0.0.1",
  "description": "Easier Javascript Apps with AngularJS",
  "main": "server/server.js",
  "author": "Tom Ashworth",
  "license": "MIT",
  "dependencies": {
    "express": "~3.0.6",
    "mongoose": "~3.5.4"
  }
}
4

2 回答 2

3

看起来您的包裹名称无效。见https://docs.npmjs.com/files/package.json

于 2013-08-13T04:47:10.767 回答
2

您的“名称”由以下代码传递:

function ensureValidName (name, strict) {
  if (name.charAt(0) === "." ||
      name.match(/[\/@\s\+%:]/) ||
      name !== encodeURIComponent(name) ||
      (strict && name !== name.toLowerCase()) ||
      name.toLowerCase() === "node_modules" ||
      name.toLowerCase() === "favicon.ico") {
        throw new Error("Invalid name: " + JSON.stringify(name))
  }
}

它不能以“。”开头。并且它不能有任何特殊字符,所以在你的情况下,我认为 $ 我会抛出错误。

一般规则是坚持使用连字符或下划线分隔的单词,并且不包含任何变量。

于 2015-02-02T11:30:05.290 回答