【问题标题】:node.js npm install errornode.js npm 安装错误
【发布时间】:2015-02-18 19:55:04
【问题描述】:

我知道这个话题已经出现了很多次,但没有一个能解决我的问题。我正在实施一个平均堆栈。这需要这些依赖项。

这是我正在使用的 package.json 文件。

{
    "name": "name",
    "version": "0.0.1",
    "description": "Video streaming application",
    "author": "First Last",
    "contributors": [{
        "name": "First Last",
        "email": "email@email.com"
    }],
    "scripts": {
        "start": "node bin/www.js"},
    "main": "bin/www.js",
    "keywords":[    
        "webrtc",
        "keyword2",
        "streaming",
        "video"
    ],
    "dependencies": {
        "express": "~4.2.0",
        "body-parser": "~1.0.0",
        "mongoose": "~3.8.11",
        "socket.io": "~1.2.1",
        "angular": "~1.3.7",
        "node-uuid": "~1.4.0"
    },
    "private": true,
    "license": "MIT"
}

这是我在使用“npm install”命令时遇到的错误。

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files (x86)\\nodejs\\\\node.exe',
1 verbose cli   'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install' ]
2 info using npm@1.4.28
3 info using node@v0.10.33
4 verbose node symlink C:\Program Files (x86)\nodejs\\node.exe
5 error install Couldn't read dependencies
6 error Failed to parse json
6 error Unexpected token }
7 error File: C:\Users\name\Desktop\htdocs\package.json
8 error Failed to parse package.json data.
8 error package.json must be actual JSON, not just JavaScript.
8 error
8 error This is not a bug in npm.
8 error Tell the package author to fix their package.json file. JSON.parse
9 error System Windows_NT 6.2.9200
10 error command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
11 error cwd C:\Users\name\Desktop\htdocs
12 error node -v v0.10.33
13 error npm -v 1.4.28
14 error file C:\Users\name\Desktop\htdocs\package.json
15 error code EJSONPARSE
16 verbose exit [ 1, true ]

【问题讨论】:

  • 您确定这就是您使用的确切文件内容吗?它验证得很好,至少对我来说是这样。
  • 不使用 UTF-8 BOM 保存 package.json。
  • 正如 Gergo 所说。见:stackoverflow.com/a/17966959/28779
  • 我的记事本已经设置为没有 BOM 的 UTF-8。所以这不是问题。 @GergoErdosi

标签: javascript node.js npm package.json


【解决方案1】:

我仍然不知道如何让它在 Windows 8、notepad++ 上运行。今天是它让我失望的第一天。现在我知道 linux 是光,而 windows 只是一个虚假的希望。话虽如此。我刚上了我的linux盒子。

在 vi 中编写了完全相同的文件,并且成功了。
保存它,将其转移到 Windows 并且它工作。

【讨论】:

    猜你喜欢
    • 2015-06-16
    • 2014-08-27
    • 2011-11-12
    • 2016-03-11
    • 1970-01-01
    • 1970-01-01
    • 2011-11-22
    • 2023-03-30
    • 2019-02-14
    相关资源
    最近更新 更多