当我尝试在Ubuntu 16.04 LTS的终端内安装:alphaunlimitedg@AUNs-PC:~/chatapplication$ npm install
时。
这是我的聊天应用程序,我正在努力:
{
"name":"chat",
"version":"0.0.1",
"private":"true",
"dependencies":
{
"socket.io":"1.4.8",
"express":"4.14.0",
}
}
我收到此错误:
alphaunlimitedg@AUNs-PC:~$ npm info socket.io version
1.4.8
alphaunlimitedg@AUNs-PC:~$ npm info express version
4.14.0
alphaunlimitedg@AUNs-PC:~$ cd chat application
bash: cd: chat: No such file or directory
alphaunlimitedg@AUNs-PC:~$ cd chat application
bash: cd: chat: No such file or directory
alphaunlimitedg@AUNs-PC:~$ cd /home/chat application
bash: cd: /home/chat: No such file or directory
alphaunlimitedg@AUNs-PC:~$ cd /home/chat application/
bash: cd: /home/chat: No such file or directory
alphaunlimitedg@AUNs-PC:~$ pwd
/home/alphaunlimitedg
alphaunlimitedg@AUNs-PC:~$ cd /home/alphaunlimitedg/chat application
bash: cd: /home/alphaunlimitedg/chat: No such file or directory
alphaunlimitedg@AUNs-PC:~$ cd /home/alphaunlimitedg/chat application/
bash: cd: /home/alphaunlimitedg/chat: No such file or directory
alphaunlimitedg@AUNs-PC:~$ cd chatapplication
alphaunlimitedg@AUNs-PC:~/chatapplication$ npm install
npm ERR! Linux 4.4.0-28-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.2.2
npm ERR! npm v3.9.5
npm ERR! file /home/alphaunlimitedg/chatapplication/package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Unexpected token '.' at 3:15
npm ERR! "version":""0.0.1",
npm ERR! ^
npm ERR! File: /home/alphaunlimitedg/chatapplication/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! /home/alphaunlimitedg/chatapplication/npm-debug.log
alphaunlimitedg@AUNs-PC:~/chatapplication$ npm install
npm ERR! Linux 4.4.0-28-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.2.2
npm ERR! npm v3.9.5
npm ERR! file /home/alphaunlimitedg/chatapplication/package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Trailing comma in object at 8:2
npm ERR! }
npm ERR! ^
npm ERR! File: /home/alphaunlimitedg/chatapplication/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! /home/alphaunlimitedg/chatapplication/npm-debug.log
alphaunlimitedg@AUNs-PC:~/chatapplication$ npm install
npm ERR! Linux 4.4.0-28-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.2.2
npm ERR! npm v3.9.5
npm ERR! file /home/alphaunlimitedg/chatapplication/package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! No value found for key dependencies at 5:17
npm ERR! "dependencies":,
npm ERR! ^
npm ERR! File: /home/alphaunlimitedg/chatapplication/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! /home/alphaunlimitedg/chatapplication/npm-debug.log
alphaunlimitedg@AUNs-PC:~/chatapplication$ npm install
npm ERR! Linux 4.4.0-28-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.2.2
npm ERR! npm v3.9.5
npm ERR! file /home/alphaunlimitedg/chatapplication/package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Trailing comma in object at 9:2
npm ERR! }
npm ERR! ^
npm ERR! File: /home/alphaunlimitedg/chatapplication/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! /home/alphaunlimitedg/chatapplication/npm-debug.log
alphaunlimitedg@AUNs-PC:~/chatapplication$ npm install
npm ERR! Linux 4.4.0-28-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.2.2
npm ERR! npm v3.9.5
npm ERR! file /home/alphaunlimitedg/chatapplication/package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Trailing comma in object at 10:1
npm ERR! }
npm ERR! ^
npm ERR! File: /home/alphaunlimitedg/chatapplication/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! /home/alphaunlimitedg/chatapplication/npm-debug.log
我已经尝试过多次尝试,因为您可以看到执行npm install命令行。
但由于某种原因,这并没有起作用,我猜测它是不是我的操作系统在Ubuntu中不支持或.json必须是一个真正的JSON文件的版本错误/问题在代码中还没有完成?而不只是JavaScript,因为错误描述了自己。
有人可以帮我解决这个问题吗?
答案 0 :(得分:0)
您的文件无效,请删除依赖项中的最后一个逗号:
{
"name":"chat",
"version":"0.0.1",
"private":"true",
"dependencies":
{
"socket.io":"1.4.8",
"express":"4.14.0"
}
}
下次使用JSON验证器,例如this,您就会发现文件中存在错误:
Error: Parse error on line 7:
...ss": "4.14.0", } }
----------------------^
Expecting 'STRING', got '}'
另外,查看输出,如果创建一个带空格的目录,则需要将其转义才能访问它,所以:
cd chat application/
应该是
cd chat\ application/