2

I am trying to setup Github actions to npm publish my package. But I got this error When I move on execute

Error: Process completed with exit code 1.

My workflows/publish.yml file looks like the following:

name: publish

on:
  push:
    branches: [ main ]
 

jobs:
  release:
    
    name: publish
    runs-on: windows-latest


    steps:
    - name: Checkout
      uses: actions/checkout@v2.3.4
    - name: Setup Node.js environment
      uses: actions/setup-node@v2.2.0
      with:
        node-version: 14
        registry-url : https://registry.nmpjs.org
    - name: publish
      run: npm publish --access public
      env:
          NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}

enter image description here

  • The error most likely means that the file `package.json` does not exist. If it does, please share with us that file; otherwise, go to the directory and run `npm init` in the command line, follow the directions, and try again. It should work. – code Jul 01 '21 at 05:17
  • 1
    share your `package.json` file – Amir Saleem Jul 01 '21 at 05:17
  • @AmirSaleem here is my `package.json` file ( https://gist.github.com/c5ee85ede67d6f605f99f674a4665494.git ) – Mohammad Sakib Mahmood Jul 01 '21 at 05:35
  • It seems the syntax of your package.json is incorrect. How did you create it? – Apoorva Chikara Jul 01 '21 at 05:48
  • it's not a complete file. The package json must be a valid json. a json has curly braces in start and end. Your package json file is broken – Amir Saleem Jul 01 '21 at 05:54
  • @ApoorvaChikara I create it by using the command prompt. i just added the JSON file, not all files are including that link, and also know that there are a few changes but my concern is different than where is wrong to publish my package by using GitHub. action. – Mohammad Sakib Mahmood Jul 01 '21 at 05:55
  • @AmirSaleem i just added the error that I get right now. after following your instruction. – Mohammad Sakib Mahmood Jul 01 '21 at 07:33
  • ok checking the error – Amir Saleem Jul 01 '21 at 07:39
  • @MohammadSakibMahmood Your `NODE_AUTH_TOKEN ` must have appropriate access in order to publish. Verify this. – Amir Saleem Jul 01 '21 at 07:43
  • This might help: https://docs.npmjs.com/configuring-your-registry-settings-as-an-npm-enterprise-user – Amir Saleem Jul 01 '21 at 07:46
  • @MohammadSakibMahmood if you are using npm registry, you need an `.npmrc` file with correct token and username. Alternatively you can use github registry by replacing the `registry-url` with `registry-url: https://npm.pkg.github.com/` – Amir Saleem Jul 01 '21 at 07:51

1 Answers1

0

Your package.json file is broken.

{
  "name": "@sakibb019/npx-card",
  "version": "1.0.0",
  "description": "",
  "main": "card.js",
  "scripts": {
    "dev": "nodemon card.js"
  },
  "keywords": [],
  "author": "",
  "repository": {
    "url": "git://github.com/sakibb019/test.git"
  },
  "license": "ISC",
  "dependencies": {
    "boxen": "^5.0.1",
    "chalk": "^4.1.1",
    "clear": "^0.1.0",
    "inquirer": "^8.1.0"
  }
}

I've added the missing braces, still, you would need to find a complete package JSON file. There should be more content after "inquirer": "^8.1.

Amir Saleem
  • 2,912
  • 3
  • 21
  • 35