I completely new to this but

PLEASE help us help you by writing a good post!
github repo: GitHub - Jomar77/The-Jomar-Project at 8e08830ca7bb3642ee79b2e71ebf7eec148ec994

netlify site name: jomarproject.netlify.app

SO I just learned to make a website today. so this is my first time deploying anywhere and youtube suggested that I go netlify. below is the deploy log and I don’t understand a thing. pls help me (also a kid)

8:47:37 PM: Build ready to start
8:47:40 PM: build-image version: 122b31996ccaffd45d820a452d6227f8312110cc (focal)
8:47:40 PM: build-image tag: v4.5.3
8:47:40 PM: buildbot version: 96522259b56227ab6642290e1a540b326f0458b4
8:47:40 PM: Fetching cached dependencies
8:47:40 PM: Starting to download cache of 4.7MB
8:47:40 PM: Finished downloading cache in 182.514066ms
8:47:40 PM: Starting to extract cache
8:47:40 PM: Finished extracting cache in 94.968686ms
8:47:40 PM: Finished fetching cache in 279.10114ms
8:47:40 PM: Starting to prepare the repo for build
8:47:41 PM: Preparing Git Reference refs/heads/master
8:47:41 PM: Parsing package.json dependencies
8:47:41 PM: Failed to generate package.json data, continuing with build
8:47:42 PM: Starting build script
8:47:42 PM: Installing dependencies
8:47:42 PM: Python version set to 2.7
8:47:43 PM: Downloading and installing node v16.14.0…
8:47:43 PM: Downloading https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz…
8:47:44 PM: Computing checksum with sha256sum
8:47:44 PM: Checksums matched!
8:47:48 PM: Now using node v16.14.0 (npm v8.3.1)
8:47:48 PM: Started restoring cached build plugins
8:47:48 PM: Finished restoring cached build plugins
8:47:48 PM: Attempting ruby version 2.7.2, read from environment
8:47:50 PM: Using ruby version 2.7.2
8:47:50 PM: Using PHP version 8.0
8:47:50 PM: Started restoring cached node modules
8:47:50 PM: Finished restoring cached node modules
8:47:51 PM: Installing NPM modules using NPM version 8.3.1
8:47:52 PM: npm ERR! code EJSONPARSE
8:47:52 PM: npm ERR! path /opt/build/repo/package.json
8:47:52 PM: npm ERR! JSON.parse Unexpected end of JSON input while parsing empty string
8:47:52 PM: npm ERR! JSON.parse Failed to parse JSON data.
8:47:52 PM: npm ERR! JSON.parse Note: package.json must be actual JSON, not just JavaScript.
8:47:52 PM: npm ERR! A complete log of this run can be found in:
8:47:52 PM: npm ERR! /opt/buildhome/.npm/_logs/2022-02-10T12_47_51_781Z-debug-0.log
8:47:52 PM: Error during NPM install
8:47:52 PM: Build was terminated: Build script returned non-zero exit code: 1
8:47:52 PM: Creating deploy upload records
8:47:52 PM: Failing build: Failed to build site
8:47:52 PM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 1
8:47:52 PM: Finished processing build request in 11.987691347s

I’ll try and help you interpret your error log:

^ The system is about to try and install packages via the npm package manager.

^ It failed to parse (basically β€˜read & interpret’) the contents of the package.json file because it isn’t in the right format. It indicates it is an empty file, which results in an β€˜empty string’ and that is not valid JSON (which is the format it requires).

^ The build has failed during the npm install.

If you check the package.json file in the repo, you’ll see that it’s empty.

You could try any of the following…

  • If it’s not necessary, removing the package.json file from the repo
  • Changing the package.json file to contain just {} (which is an empty object, but valid JSON)
  • Running npm init in your project directory (if you have npm installed), which will walk you through creating a package.json file with some defaults
4 Likes

hey @nathanmartin, thank you so much for stepping in and being so thoughful in helping a newbie troubleshoot. Really appreciate the time you spend in here answering questions and getting people unstuck :handshake:

@qweasdf , nathan has done a better job than i could explaining, i don’t have anything to add here (except for…if you don’t need a package.json, then it’s likely the project doesn’t need to be built. If it doesn’t need to be built, then you shouldn’t have a build command entered into the UI. Do you? it might be helpful for us if you popped a screenshot of your build settings.)

We’re pretty close to getting this to work, i think.

3 Likes

Hi there! first of all, massive thanks for replying. Second, I learned that I need to download node.js first before doing any of this stuff. Third, it’s still broken. I did npm install express then npm install netlify-lambda. THEN it said I have 5 high vulnerabilities and some folder named node modules suddenly popped up which I kid u not was scary. (is this hacking or some related stuff?). Then I committed these changes regardless of me not knowing what will happen. THEN I did what Mr. Nathan martin said to delete my empty package.json.

Per request, here is my build settings:

11:01:40 AM: Build ready to start
11:01:44 AM: build-image version: 122b31996ccaffd45d820a452d6227f8312110cc (focal)
11:01:44 AM: build-image tag: v4.5.3
11:01:44 AM: buildbot version: 9916c4a6a180865eb3ec6a342637fd13b29e1096
11:01:44 AM: Building without cache
11:01:44 AM: Starting to prepare the repo for build
11:01:45 AM: No cached dependencies found. Cloning fresh repo
11:01:45 AM: git clone GitHub - Jomar77/The-Jomar-Project
11:01:46 AM: Preparing Git Reference refs/heads/master
11:01:47 AM: Parsing package.json dependencies
11:01:48 AM: Starting build script
11:01:48 AM: Installing dependencies
11:01:48 AM: Python version set to 2.7
11:01:49 AM: Downloading and installing node v16.14.0…
11:01:49 AM: Downloading https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz…
11:01:49 AM: Computing checksum with sha256sum
11:01:50 AM: Checksums matched!
11:01:53 AM: Now using node v16.14.0 (npm v8.3.1)
11:01:53 AM: Started restoring cached build plugins
11:01:53 AM: Finished restoring cached build plugins
11:01:53 AM: Attempting ruby version 2.7.2, read from environment
11:01:54 AM: Using ruby version 2.7.2
11:01:54 AM: Using PHP version 8.0
11:01:54 AM: Started restoring cached node modules
11:01:55 AM: Finished restoring cached node modules
11:01:55 AM: Installing NPM modules using NPM version 8.3.1
11:02:00 AM: npm WARN deprecated source-map-url@0.4.1: See GitHub - lydell/source-map-url: [DEPRECATED] Tools for working with sourceMappingURL comments.
11:02:00 AM: npm WARN deprecated urix@0.1.0: Please see GitHub - lydell/urix: [DEPRECATED] Makes Windows-style paths more unix and URI friendly.
11:02:00 AM: npm WARN deprecated resolve-url@0.2.1: GitHub - lydell/resolve-url: [DEPRECATED] Like Node.js’ `path.resolve`/`url.resolve` for the browser.
11:02:00 AM: npm WARN deprecated source-map-resolve@0.5.3: See GitHub - lydell/source-map-resolve: [DEPRECATED] Resolve the source map and/or sources for a generated file.
11:02:02 AM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
11:02:03 AM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
11:02:04 AM: added 624 packages, and audited 625 packages in 8s
11:02:04 AM: 32 packages are looking for funding
11:02:04 AM: run npm fund for details
11:02:04 AM: 5 high severity vulnerabilities
11:02:04 AM: To address all issues, run:
11:02:04 AM: npm audit fix
11:02:04 AM: Run npm audit for details.
11:02:04 AM: NPM modules installed
11:02:05 AM: Started restoring cached go cache
11:02:05 AM: Finished restoring cached go cache
11:02:05 AM: go version go1.16.5 linux/amd64
11:02:05 AM: go version go1.16.5 linux/amd64
11:02:05 AM: Installing missing commands
11:02:05 AM: Verify run directory
11:02:06 AM: ​
11:02:06 AM: ────────────────────────────────────────────────────────────────
11:02:06 AM: Netlify Build
11:02:06 AM: ────────────────────────────────────────────────────────────────
11:02:06 AM: ​
11:02:06 AM: ❯ Version
11:02:06 AM: @netlify/build 26.2.7
11:02:06 AM: ​
11:02:06 AM: ❯ Flags
11:02:06 AM: baseRelDir: true
11:02:06 AM: buildId: 6205d194ef9c0111fa8ab9ac
11:02:06 AM: deployId: 6205d194ef9c0111fa8ab9ae
11:02:06 AM: ​
11:02:06 AM: ❯ Current directory
11:02:06 AM: /opt/build/repo
11:02:06 AM: ​
11:02:06 AM: ❯ Config file
11:02:06 AM: No config file was defined: using default values.
11:02:06 AM: ​
11:02:06 AM: ❯ Context
11:02:06 AM: production
11:02:06 AM: ​
11:02:06 AM: ────────────────────────────────────────────────────────────────
11:02:06 AM: 1. Build command from Netlify app
11:02:06 AM: ────────────────────────────────────────────────────────────────
11:02:06 AM: ​
11:02:06 AM: $ npm run build
11:02:07 AM: npm ERR! Missing script: β€œbuild”
11:02:07 AM: npm ERR!
11:02:07 AM: npm ERR! To see a list of scripts, run:
11:02:07 AM: npm ERR! npm run
11:02:07 AM: npm ERR! A complete log of this run can be found in:
11:02:07 AM: npm ERR! /opt/buildhome/.npm/_logs/2022-02-11T03_02_07_005Z-debug-0.log
11:02:07 AM: ​
11:02:07 AM: ────────────────────────────────────────────────────────────────
11:02:07 AM: β€œbuild.command” failed
11:02:07 AM: ────────────────────────────────────────────────────────────────
11:02:07 AM: ​
11:02:07 AM: Error message
11:02:07 AM: Command failed with exit code 1: npm run build
11:02:07 AM: ​
11:02:07 AM: Error location
11:02:07 AM: In Build command from Netlify app:
11:02:07 AM: npm run build
11:02:07 AM: ​
11:02:07 AM: Resolved config
11:02:07 AM: build:
11:02:07 AM: command: npm run build
11:02:07 AM: commandOrigin: ui
11:02:07 AM: publish: /opt/build/repo/dist
11:02:07 AM: publishOrigin: ui
11:02:07 AM: Caching artifacts
11:02:07 AM: Started saving node modules
11:02:07 AM: Finished saving node modules
11:02:07 AM: Started saving build plugins
11:02:07 AM: Finished saving build plugins
11:02:07 AM: Started saving pip cache
11:02:07 AM: Finished saving pip cache
11:02:07 AM: Started saving emacs cask dependencies
11:02:07 AM: Finished saving emacs cask dependencies
11:02:07 AM: Started saving maven dependencies
11:02:07 AM: Finished saving maven dependencies
11:02:07 AM: Started saving boot dependencies
11:02:07 AM: Finished saving boot dependencies
11:02:07 AM: Started saving rust rustup cache
11:02:07 AM: Finished saving rust rustup cache
11:02:07 AM: Started saving go dependencies
11:02:07 AM: Finished saving go dependencies
11:02:10 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:02:10 AM: Creating deploy upload records
11:02:10 AM: Failing build: Failed to build site
11:02:10 AM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
11:02:10 AM: Finished processing build request in 25.473840745s

^ That’s not strictly true, as it’s possible to deploy a website on Netlify with nothing but a single .html file. But it is a requirement of some of the tooling that it looks like you’re trying to use.

^ You won’t need express to serve your site when deployed to Netlify, it’s also unlikely you will need netlify-lambda.

If you’re trying to use express to serve the site locally, instead of either you should probably check out the Netlify CLI which provides tooling for local development and working with functions.

^ The node_modules folder is where the packages that you install via npm are installed (along with their dependencies). You can read more about it online, and run npm audit to see more details about the specific vulnerabilities that are in your dependencies.

^ Your build is failing because the build command specified in Netlify is npm run build, which is trying to run an npm script called build, but if you check your package.json, it doesn’t contain a script called build, only the default placeholder one called test:

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1"
},

If you did want your build command in Netlify to be npm run build, you would modify the package.json to contain your real build command. If you aren’t actually running a script to build anything, then you might not need a build command at all. If that’s the case you could set it to blank in Netlify’s configuration, or leave Netlify calling npm run build but set the package.json to have a blank entry for the build script:

"scripts": {
  "build": ""
},

With the configuration that you’ve shown, you’re likely to run into an issue with your β€œPublish directory”.
You have it set to dist, but there isn’t a dist folder in your repo, (nor is there any code that builds one).

What everything needs to be set to ultimately depends on what you’re trying to do, so it’s difficult to provide any kind of exact guidance.

However if you fix the build script issue explained above, and then move these files & folders from:

  • index.html
  • assets/
  • images/

To:

  • dist/index.html
  • dist/assets/
  • dist/images/

You’ll probably find that the site deploys.

2 Likes

Hello there Mr nathanmartin! Thank you for replying to my inquiries once again. Thanks to you I did publish my website successfully.

EDIT:

MR. nathanmartin, Thank you so much for your help. It didn’t work still BUT upon browsing the forums. I learned that Philippines ISPs block netlify for some reason. It was working waaaaay before but I needed to use a VPN to access the site. Thank you once again!

2 Likes