1
votes

I'm in the middle of making a website, and I use the command npm start to put it up on localhost. However, all of a sudden it stopped working after I had created two workspaces on Visual Studio Code Editor. It only gives me an error.

This is what the error looks like:

npm ERR! path C:\Users\audre\first-blog\package.json

npm ERR! code ENOENT

npm ERR! errno -4058

npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\audre\first-blog\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! C:\Users\audre\AppData\Roaming\npm-cache_logs\2018-05-29T07_42_13_915Z-debug.log

I have no idea what that means. Can anyone help me? Thanks!

Edit: My package.json file contains the following:

{
  "name": "pug-starter",
  "version": "1.0.0",
  "description": "Simple pug (jade) starter [framework] enabling faster delivery of HTML & CSS projects to a private server and/or automatic deployment of GitHub pages.",
  "main": "index.js",
  "scripts": {
    "dev": "gulp dev",
    "start": "gulp dev",
    "prod": "gulp build --production",
    "deploy": "gulp build --production && gulp deploy && gulp clean:ghpages",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "//": "CUSTOM CONFIGURATION",
  "config": {
    "directory": {
      "development": "tmp",
      "production": "build",
      "ghpages": ".publish",
      "source": "src",
      "data": "_data",
      "component": "_component",
      "layout": "_layout",
      "asset": "_asset",
      "image": "image",
      "font": "font",
      "templateCollection": [
        "article",
        "product"
      ]
    },
    "render": {
      "sourceFileChange": false,
      "url": {
        "//": "this is recommended to avoid Linux/Windows capitalization issue",
        "htmlExtensionOn": false,
        "toLowercase": true
      }
    },
    "entry": {
      "cssExternal": "style**.{scss,sass}",
      "cssInline": "inline**.{scss,sass}",
      "css": {
        "inline": false,
        "external": true
      }
    }
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/marianzburlea/pug-starter.git"
  },
  "keywords": [
    "pug",
    "starter",
    "jade",
    "starter"
  ],
  "author": "Marian Zburlea",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/marianzburlea/pug-starter/issues"
  },
  "homepage": "https://github.com/marianzburlea/pug-starter#readme",
  "devDependencies": {
    "autoprefixer": "^6.7.5",
    "babel-core": "^6.26.0",
    "babel-eslint": "^8.1.2",
    "babel-plugin-add-module-exports": "^0.2.1",
    "babel-preset-env": "^1.6.1",
    "browser-sync": "^2.18.8",
    "eslint": "^3.16.1",
    "foldero": "^0.1.1",
    "gulp": "github:gulpjs/gulp#4.0",
    "gulp-cached": "^1.1.1",
    "gulp-changed": "^2.0.0",
    "gulp-changed-in-place": "^2.2.0",
    "gulp-debug": "^3.1.0",
    "gulp-gh-pages": "^0.5.4",
    "gulp-if": "^2.0.2",
    "gulp-imagemin": "^3.1.1",
    "gulp-inline-source": "^3.0.0",
    "gulp-load-plugins": "^1.5.0",
    "gulp-plumber": "^1.1.0",
    "gulp-postcss": "^6.3.0",
    "gulp-pug": "^3.2.0",
    "gulp-rename": "^1.2.2",
    "gulp-sass": "^3.1.0",
    "gulp-sourcemaps": "^2.4.1",
    "imagemin-jpegoptim": "^5.0.0",
    "imagemin-pngquant": "^5.0.0",
    "imagemin-svgo": "^5.2.0",
    "jstransformer-markdown-it": "^2.0.0",
    "merge-stream": "^1.0.1",
    "minimist": "^1.2.0"
  }
}
4
Does the file C:\Users\audre\first-blog\package.json exist on your machine?tbrk
What's the content of the debug logfile?Dominique
I think so. I've got a file that's labeled, "package.json," if that's what you mean, tbrk.user9832881

4 Answers

1
votes

When all else fails, remove/reinstall node.js completely. When you get wild errors all over the board on all of your node env commands, it means node is corrupted or wrong in some way.

0
votes

Use a process manager that will take care of environment.

few options are

forever(https://www.npmjs.com/package/forever)

with this, you start the website on localhost using forever start <mainfilename>

PM2 (https://www.npmjs.com/package/pm2)

with this, you start the website on localhost using pm2 start <mainfilename>

With process managers, you are abstracted from the environment specifications until you need to have something more specific.

0
votes

ENOENT means, where you are running npm start command that directory does not contain package.json file.

First, make sure you are in the correct directory and it has package.json file.

Also, if there is no package.json file, you can initialize it using npm init command.

If this is not the case, feel free to drop comments to correct me.

0
votes

If you have multiple versions of nodejs on your machine and are running node version manager (nvm), be sure to set your version correctly in terminal.

ex. nvm use v9.5.0