I'm running npm ci on Node 16 in GitHub workflow actions and keep getting the following error:
npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR! https://www.npmjs.com/forgot
npm ERR!
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR! npm login
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2022-01-10T11_38_28_617Z-debug.log
Error: Process completed with exit code 1.
I tried deleting the package-lock.json file and running npm i locally and uploading the new file. But it did not make a difference.
Workflow file
name: Node.js CI
on:
push:
branches: [ "*" ]
pull_request:
branches: [ "*" ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- name: Build the Docker image and run tests
uses: actions/checkout#v2
- run: npm ci
- run: npm test
Please advise how I can resolve this.
Looks like some of the packages in your package-lock.json file are in private registries.
You need to login to that registry as it is saying in the error. Otherwise NPM cannot pull those packages.
Related
I'm trying to publish a new package to npm, public.
I have the following workflow:
# This workflow will run tests using node and then publish a package to GitHub
Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
name: Node.js Package
on:
release:
types: [created]
jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm login
- run: npm config set access public
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
But I get the following error:
npm notice
npm notice 📦 #orgname/pdf-image#1.2.2
npm notice === Tarball Contents ===
npm notice 135B Dockerfile
npm notice 135B Dockerfile12
npm notice 1.1kB LICENSE
npm notice 6.8kB index.js
npm notice 5.9kB tests/test-main.js
npm notice 530B package.json
npm notice 2.1kB README.md
npm notice 325.2kB tests/test.pdf
npm notice 1.1kB .github/workflows/node.js.yml
npm notice 664B .github/workflows/npm-publish.yml
npm notice === Tarball Details ===
npm notice name: #orgname/pdf-image
npm notice version: 1.2.2
npm notice package size: 322.6 kB
npm notice unpacked size: 343.6 kB
npm notice shasum: d362e3a6c95d12b2329ed608495c45580bb8de15
npm notice integrity: sha512-OpurprtbmR7By[...]V553ykjYtaOrA==
npm notice total files: 10
npm notice
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/#orgname%2fpdf-image - Not found
npm ERR! 404
npm ERR! 404 '#orgname/pdf-image#1.2.2' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
Please advise how can I resolve this issue.
npm login is unnecessary here.
You need to do 3 steps to make it work:
Config the job on your yml file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- uses: actions/setup-node#v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Define NPM_TOKEN access token in your npmjs account under access tokens, make sure it's an automation token:
Copy this token and define him in your GitHub repository:
I am trying to setup a github actions bot that uses composite to build when the action runs. Notably, this isn't required, and I know that ncc would also achieve the same thing, but I'm curious if it's possible to make this work in a sustainable way.
For some context, I'm trying to run my alita-moore/EIP-Bot private action with the yaml script being...
name: "Auto Merge EIP"
description: "A bot that lints EIP edits, finds common errors, and can auto-merge"
inputs:
GITHUB-TOKEN:
description: |-
The Github token to be used by this bot when merging, posting comments, or requesting reviewers
required: true
VERSION:
description: version of the action; this is required because of how actions work
required: true
runs:
using: "composite"
steps:
- run: cd /home/runner/work/_actions/alita-moore/EIP-Bot/${{ inputs.VERSION }} && npm ci && npm run build && GITHUB_TOKEN=${{ inputs.GITHUB-TOKEN }} node build/index.js
shell: bash
And this currently runs with a given repo's workflow yaml being
on: [pull_request]
jobs:
auto_merge_bot:
runs-on: ubuntu-latest
name: EIP Auto-Merge Bot
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Setup Node.js Enviornment
uses: actions/setup-node#v2
with:
node-version: '14'
- name: auto-merge-bot
uses: alita-moore/EIP-Bot#1.0.8
id: auto-merge-bot
with:
GITHUB-TOKEN: ${{ secrets.TOKEN }}
VERSION: 1.0.8
You may have noticed that before the npm ci && npm run build I first had to cd /home/runner/work/_actions/alita-moore/EIP-Bot/${{ inputs.VERSION }}
If you don't do this it'll throw the following error
Run alita-moore/EIP-Bot#1.0.1
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/runner/work/EIPs/EIPs/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/runner/work/EIPs/EIPs/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/runner/.npm/_logs/2021-03-14T09_02_26_002Z-debug.log
Error: Process completed with exit code 254.
Is there a better way to do this?
You can use ${{github.action_path}} for the path of the directory containing the action definition file action.yaml:
[...]
runs:
using: "composite"
steps:
- run: cd ${{github.action_path}} && npm ci && npm run build && GITHUB_TOKEN=${{ inputs.GITHUB-TOKEN }} node build/index.js
shell: bash
github.action_path | string | The path where your action is located. You can use this path to easily access files located in the same repository as your action. This attribute is only supported in composite run steps actions.
https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
The value for ${{ github.action_path }} is also available by default as the environment variable GITHUB_ACTION_PATH, so something like this is also an option:
[...]
- uses: actions/setup-python#v4
with:
python-version: '3.9'
- name: install-dependencies
run: pip install -r $GITHUB_ACTION_PATH/requirements.txt
shell: bash
This assumes the requirements.txt file is at the root of my composite actions directory.
getting errors in the terminal when trying to use npm to deploy a website on github
I have no idea what to try
PS C:\Users\user\modern_portfolio> npm run deploy
> modern_portfolio#1.0.0 deploy C:\Users\user\modern_portfolio
> gh-pages -d dist
The "file" argument must be of type string. Received type undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! modern_portfolio#1.0.0 deploy: `gh-pages -d dist`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the modern_portfolio#1.0.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Roaming\npm-cache\_logs\2019-08-04T04_12_42_515Z-debug.log
Newer version 2.1 has some issue. They are probably working on it. Revert back to 2.0.1.
Reinstall Github pages with a specific version:
npm uninstall gh-pages
npm i gh-pages#2.0.1
npm run deploy // as usual
I've forked a project from GitHub, and I want to run the command npm run sjs, but it gives me an error. This is what it says:
> vodafone#0.1.0 sjs C:\Users\audre\fantastic-website\vodafone\vodafone
> json-server ./data/phones.json -p 1234 --watch
'json-server' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vodafone#0.1.0 sjs: `json-server ./data/phones.json -p 1234 --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vodafone#0.1.0 sjs script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\audre\AppData\Roaming\npm-cache\_logs\2018-07-07T09_35_19_168Z-debug.log
Please help; thanks a lot!
TL;DR;
just run npm install json-server and you'll be OK.
Explanation
npm scripts
When running a script via npm, node is looking for the command in:
local node_modules/.bin folder (things that are in package.json)
global node_modules/.bin folder (things that you've installed with npm install -g my-package)
your standard shell PATH
your problem
In that case, I guess that the creator of this repo had the json-server package installed, either locally without stating so in package.json or globally.
recommendation
My recommendation is that you run npm install --save json-server and update the package.json file.
Actually, I did it already for you: https://github.com/catezee/vodafone/pull/1
When I try to create a package.json file using npm init I keep getting the following:
npm http GET https://registry.npmjs.org/init
npm http 304 https://registry.npmjs.org/init
npm http GET https://registry.npmjs.org/daemon
npm http 304 https://registry.npmjs.org/daemon
init#0.1.2 node_modules/init
└── daemon#1.1.0
What is wrong? I have looked everywhere and I cannot find an answer.
Here is what I get when I run the following command:
Amens-Mac-mini:~ amenmojara$ npm init =ddd
npm http GET https://registry.npmjs.org/%3Dddd
npm http GET https://registry.npmjs.org/init
npm http 304 https://registry.npmjs.org/init
npm http 404 https://registry.npmjs.org/%3Dddd
npm ERR! 404 '%3Dddd' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.
npm ERR! System Darwin 13.0.0
npm ERR! command "/usr/local/Cellar/node/0.10.26/bin/node" "/usr/local/bin/npm" "install" "init" "=ddd"
npm ERR! cwd /Users/amenmojara
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code E404
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/amenmojara/npm-debug.log
npm ERR! not ok code 0
Try this.
Go to terminal.
Change directory location where you want to create a file.
cd your_destination_folder
Type npm init and press enter.
It ask for name, version, description, entry point, test command, git repository, keywords, author, license. Pass those values.
Then it prompt, Is this ok? (yes). Enter yes.
Hurray, your package.json file is created.
You are doing npm install init instead of npm init. Just check if your npm <something> is not aliased to npm install <something>