Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 键入'时出错;npm启动';将我的网站与本地主机连接_Node.js_Json_Linux_Npm_Sudo - Fatal编程技术网

Node.js 键入'时出错;npm启动';将我的网站与本地主机连接

Node.js 键入'时出错;npm启动';将我的网站与本地主机连接,node.js,json,linux,npm,sudo,Node.js,Json,Linux,Npm,Sudo,我正在尝试启动网页,但在终端(文件夹项目)中键入npm start时显示错误 npm ERR! syscall open npm ERR! path /home/dmarin/package.json npm ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory, open '/home/dmarin/package.json' npm ERR! enoent This is related to npm not bein

我正在尝试启动网页,但在终端(文件夹项目)中键入npm start时显示错误

npm ERR! syscall open
npm ERR! path /home/dmarin/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/dmarin/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dmarin/.npm/_logs/2020-02-20T16_05_39_782Z-debug.log

我使用php admin和apache连接到localhost中的mysql数据库。您的帮助将非常全面。

如果您想使用npm启动服务器,然后服务器将提供网页服务,那么您需要执行
npm init
,它将创建package.json

它看起来像这样:


  > npm init --yes
  Wrote to /home/ag_dubs/my_package/package.json:

  {
    "name": "my_package",
    "description": "",
    "version": "1.0.0",
    "main": "index.js",
    "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
    },
    "repository": {
      "type": "git",
      "url": "https://github.com/ashleygwilliams/my_package.git"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "bugs": {
      "url": "https://github.com/ashleygwilliams/my_package/issues"
    },
    "homepage": "https://github.com/ashleygwilliams/my_package"
  }
npm start查找pacakage.json文件或pacakage-lock.json文件。 并将启动您在package.json中提到的文件

在上述文件中,它将查找:

“main”:“index.js”


因此,您需要做的就是将index.js替换为您想要的网页。

如果您想使用npm启动服务器,然后服务器将提供网页服务,那么您需要执行
npm init
,它将创建package.json

它看起来像这样:


  > npm init --yes
  Wrote to /home/ag_dubs/my_package/package.json:

  {
    "name": "my_package",
    "description": "",
    "version": "1.0.0",
    "main": "index.js",
    "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
    },
    "repository": {
      "type": "git",
      "url": "https://github.com/ashleygwilliams/my_package.git"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "bugs": {
      "url": "https://github.com/ashleygwilliams/my_package/issues"
    },
    "homepage": "https://github.com/ashleygwilliams/my_package"
  }
npm start查找pacakage.json文件或pacakage-lock.json文件。 并将启动您在package.json中提到的文件

在上述文件中,它将查找:

“main”:“index.js”


因此,您只需将index.js替换为您想要的网页。

您是否有package.json?您似乎忘记将
cd
放入应用程序目录,错误显示您位于
/home/dmarin
目录,我猜这是你的操作系统用户主页。你有一个包.json吗?你似乎忘记了将
cd
放入app目录,错误显示你在
/home/dmarin
目录,我猜这是你的操作系统用户主页。