当我输入'npm start'时用本地主机连接我的网站时出错

问题描述 投票:1回答:1

我正在尝试启动网页,但是当我在终端中键入npm start时(在proyect文件夹中,则显示错误。

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

已连接到localhost中的mysql数据库,使用php admin和apache。您的帮助将非常有用。

node.js json linux npm sudo
1个回答
0
投票

[如果要使用npm启动服务器,然后将其提供网页,则需要执行npm init,它将创建pacakage.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文件。并启动您在pacakage.json中提到的文件。

在上面的文件中,它将寻找:

“ main”:“ index.js”

所以您需要做的就是将index.js替换为所需的网页。

© www.soinside.com 2019 - 2024. All rights reserved.