簡體   English   中英

Package.json語法錯誤?

[英]Package.json syntax error?

我正在嘗試運行npm install ,我得到了:

root@WF-DEV1:/var/www/laravel# npm install                                                                                                                              
npm ERR! install Couldn't read dependencies                                                                                                                             
npm ERR! Failed to parse json                                                                                                                                           
npm ERR! Unexpected token }                                                                                                                                             
npm ERR! File: /var/www/laravel/package.json                                                                                                                            
npm ERR! Failed to parse package.json data.                                                                                                                             
npm ERR! package.json must be actual JSON, not just JavaScript.                                                                                                         
npm ERR!                                                                                                                                                                
npm ERR! This is not a bug in npm.                                                                                                                                      
npm ERR! Tell the package author to fix their package.json file. JSON.parse  

這是我的package.json文件:

{
  "name": "bootstrap-tagsinput",
  "title": "Bootstrap Tags Input",
  "version": "0.5.0",
  "description": "jQuery plugin providing a Twitter Bootstrap user interface for managing tags.",
  "scripts": {
    "test": "karma start --single-run --no-auto-watch"
  },
  "main" : "dist/bootstrap-tagsinput.js",
  "repository": {
    "type": "git",
    "url": "git://github.com/timschlechter/bootstrap-tagsinput.git"
  },
  "author": "Tim Schlechter",
  "contributors": [{
      "name": "Luckner Jr Jean-Baptiste"
   }],
  "license": "MIT",
  "homepage": "http://timschlechter.github.io/bootstrap-tagsinput/examples/",
  "download": "http://timschlechter.github.io/bootstrap-tagsinput/build/bootstrap-tagsinput.zip",
  "keywords": [
    "tags",
    "bootstrap",
    "input",
    "select",
    "form"
  ],
  "readmeFilename": "README.md",
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-cli": "~0.1.13",
    "grunt-contrib-copy": "~0.5.0",
    "grunt-contrib-uglify": "~0.2.2",
    "grunt-jquerymanifest": "~0.1.4",
    "grunt-zip": "~0.15.0",
    "karma": "~0.12.19",
    "phantomjs": "~1.9.7-15",
    "karma-phantomjs-launcher": "~0.1.3",
    "karma-jasmine": "~0.1.5",
    "grunt-karma": "~0.8.3",
    "bower": "~1.3.8",
    "grunt-bower-task": "~0.4.0"
  },
  "banner": "/*\n * <%= pkg.name %> v<%= pkg.version %> by <%= pkg.author %>\n * <%= pkg.license.url %>\n */\n"
}

任何幫助,將不勝感激!

JSON似乎有效(我通過在線解析器對其進行了運行)。 我在Windows下運行了相同的package.json並得到以下輸出:

D:\workspace\deleteme>npm install
npm ERR! install Couldn't read dependencies
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v4.1.1
npm ERR! npm  v2.14.4
npm ERR! file D:\workspace\deleteme\package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! Unexpected token '<' at 1:1
npm ERR! <!DOCTYPE html>
npm ERR! ^
npm ERR! File: D:\workspace\deleteme\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! Please include the following file with any support request:
npm ERR!     D:\workspace\deleteme\npm-debug.log

npm-debug.log開頭是:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install' ]
2 info using npm@2.14.4
3 info using node@v4.1.1
4 verbose readDependencies loading dependencies from D:\workspace\deleteme\package.json
5 error install Couldn't read dependencies
6 verbose stack Error: Failed to parse json
6 verbose stack Unexpected token '<' at 1:1
6 verbose stack <!DOCTYPE html>
6 verbose stack ^
6 verbose stack     at parseError (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:379:11)
6 verbose stack     at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:68:23)
6 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:48:5
6 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:76:16
6 verbose stack     at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
7 verbose cwd D:\workspace\deleteme

因此, devDependencies直覺,我將您的devDependencies更改為dependencies並且該方法起作用了。 所以我沒有一個確切的答案,但是看來您的文件中肯定有npm有問題的東西-這不是JSON錯誤。

由於某種原因,錯誤的代碼在我的package.json中。 不知道如何到達那里,但我絕對沒有把它放在那里。 我重新安裝了所有內容,現在它已修復,並且正確的代碼已在其中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM