Error package.json: Name contains illegal characters

Briefly summarize the issues you have been experiencing.
I’m starting to have issues with deploying sites on Netlify. I’m not really sure how they broke but it should be noted that they are both Gatsby sites. For one of the sites, one of the build errors in local development points to an npm package that has something to do with a Gatsby plugin. Another website deploys fine locally but on Netlify I get the error:

6:40:18 PM: Installing NPM modules using Yarn version 1.13.0

6:40:18 PM: yarn install v1.13.0

6:40:18 PM: error package.json: Name contains illegal characters

6:40:18 PM: info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

6:40:18 PM: Error during Yarn install

6:40:18 PM: failed during stage 'building site': Build script returned non-zero exit code: 1

Interestingly, I get this error for both builds now so this leads me to believe that this is something to do with Netlify.

Please provide a link to your live site hosted on Netlify

https://practical-raman-142310.netlify.com/

What have you tried as far as troubleshooting goes? Do you have an idea what is causing the problem?
I’m still getting comfortable with how Netlify builds and deploys sites so I’m not 100% on how it works but I went through the build settings docs and tried building the sites locally. This worked for the site without the conflicting gatsby package and failed for the site with the busted package. My hunch is that it has something to do with my local version (npm, yarn, etc) not lining up with Netlify’s settings. I did run a couple npm updates to try to resolve the problem, so its possible that I’ve altered some version somewhere.

I’m not exactly sure how/where to verify the build settings though I understand this stuff is listed along with the build image. My initial theory was it had something to do with an outdated package or version of one of the package installers. Not sure why I have both a package.json and yarn.lock file in my src files. I don’t remember explicitly installing yarn.

Ideally I’d like to verify that the build settings and my local settings are the same but not sure where to get started with that.

Do you have any other information that is relevant, such as links to docs, libraries, or other resources?

can you post your package.json please?

6:40:18 PM: error package.json: Name contains illegal characters

is the first thing that should be investigated.

Here is the package.json for the Greystone Place iste. This file began as a clone of one of the gatsby starters, so some of the cloned info (bugs repo, etc…) still remains:

{
  "name": "Greystone Place",
  "private": true,
  "description": "A simple starter to get up and developing quickly with Gatsby",
  "version": "0.1.0",
  "author": "Dave gaskin <david@peakwebsites.ca>",
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.19",
    "@fortawesome/free-solid-svg-icons": "^5.9.0",
    "@fortawesome/react-fontawesome": "^0.1.4",
    "classnames": "^2.2.6",
    "gatsby": "^2.10.5",
    "gatsby-image": "^2.2.3",
    "gatsby-plugin-google-analytics": "^2.1.0",
    "gatsby-plugin-manifest": "^2.2.0",
    "gatsby-plugin-offline": "^2.2.0",
    "gatsby-plugin-prefetch-google-fonts": "^1.4.2",
    "gatsby-plugin-react-helmet": "^3.1.0",
    "gatsby-plugin-sass": "^2.1.0",
    "gatsby-plugin-sharp": "^2.2.1",
    "gatsby-plugin-sitemap": "^2.2.0",
    "gatsby-plugin-typography": "^2.3.0",
    "gatsby-source-filesystem": "^2.1.1",
    "gatsby-transformer-sharp": "^2.2.0",
    "hamburgers": "^1.1.3",
    "hls.js": "^0.12.4",
    "node-sass": "^4.12.0",
    "prop-types": "^15.7.2",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-helmet": "^5.2.1",
    "react-typography": "^0.16.19",
    "typography": "^0.16.19"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "start": "npm run develop",
    "format": "prettier --write \"src/**/*.js\"",
    "test": "echo \"Write tests! -> https://gatsby.app/unit-testing\""
  },
  "devDependencies": {
    "prettier": "^1.18.2"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/gatsbyjs/gatsby-starter-default"
  },
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  }
}

Thanks,

try changing the name value in the package.json to all lowercase characters and removing the whitespace and see if that changes things.

wow, that actually worked!

So I quickly noted in the npm docs that the name value is optional if you don’t plan on publishing your package but if you do, new packages cannot contain uppercase letters. Spaces seem to be fine and are URL encoded, I think.

1 Like

i’ve read conflicting things re: whitespace, so it’s always good to be on the safe side :slight_smile:
Glad that worked. :+1: