I need to install a module "express" from npm via salt-stack.
For this, I used the following script:
npm-installed:
pkg.installed:
- name: npm
npm-express-installed:
npm.installed:
- user: root
- pkgs: "express"
- dir: /opt/MyService
- require:
- pkg: npm
The installation ran successfully but on my destination I can only see
/opt/MyService/node_modules# ls
e p r s x
Is someone else here who installed npm packages via salt-stack? How do I solve this issue?
This is the solution:
npm-installed:
pkg.installed:
- name: npm
npm-packages-installed:
npm.installed:
- names:
- express
- body-parser
- user: root
- dir: /opt/MyService
- require:
- pkg: npm
Related
I have read through many stack overflow questions and official documentation from Circleci but for some reason it will not let me publish packages via ci/cd.
No matter what I do I consistently get the following
error message
I have reset the NPM_TOKEN and know that it is correct and I don't see the issue with my code. according to the docs it should work but it does not. Am I missing something obvious?
Here is what I have tried
jobs:
publish:
executor: node
steps:
- checkout
- install
- run:
name: Build package
command: yarn build // tsc builds package to the lib directory
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
- run:
name: Publish library
command: npm publish lib
also
jobs:
publish:
executor: node
steps:
- checkout
- install
- run:
name: Build package
command: yarn build // tsc builds package to the lib directory
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/project/.npmrc
- run:
name: Publish library
command: npm publish lib
and
jobs:
publish:
executor: node
steps:
- checkout
- install
- run:
name: Build package
command: yarn build
- run:
name: Publish library
command: |
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
npm publish lib
and a few other variations but they were more tinkering, the above are examples that I have seen as documentation
i've a repo with multiple react projects arranged in different subfolders
is it possible to open a specific project usign the link button?
somethig like this:
//pseudocode - this is the pat of my repo
https://gitpod.io/#https://github.com/pinale/?task=refinefirebase
this is my .gitpod.yml file:
tasks:
- name: reactstun
before: cd reactstun
init: npm install
command: npm run start
- name: refinefirebase
before: cd refinefirebase
init: npm install
command: npm run dev
- name: refineheadlessapp
before: cd refineheadlessapp
init: npm install
command: npm run dev
- name: refinemuiapp
before: cd refinemuiapp
init: npm install
command: npm run dev
I've created a public npm repository: https://www.npmjs.com/package/point-cloud-visualiser
I'm trying to run npm publish from within codebuild. I have generated a token and saved it in AWS secrets manager. I am succesfully pulling the secret in the buildspec. However I am unsure how to configure the .npmrc file so that it uses the token and doesn't tell me to login.
Currently my .npmrc looks like this:
#point-cloud-visualiser:registry=https://www.npmjs.com/package/point-cloud-visualiser
//point-cloud-visualiser/:_authToken=${NPM_TOKEN}
And my buildspec.yml looks like this:
version: 0.2
env:
secrets-manager:
NPM_TOKEN: "npm-token:npm-token"
phases:
install:
commands:
- npm install
build:
commands:
- npm run build
- npm publish
But when it fails on npm publish giving the error:
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://registry.npmjs.org/
npm ERR! need auth You need to authorize this machine using `npm adduser`
I have also tried removing the .npmrc file and using the following in the buildspec.yml:
version: 0.2
env:
secrets-manager:
NPM_TOKEN: "npm-token:npm-token"
phases:
install:
commands:
- npm install
build:
commands:
- npm run build
- npm config set registry 'https://www.npmjs.com/package/point-cloud-visualiser'
- npm config set '//npmjs.com/package/point-cloud-visualiser/:always-auth' 'true'
- npm config set '//npmjs.com/package/point-cloud-visualiser/:_authToken' '${NPM_TOKEN}'
- npm publish
But this approach gives the same result as above. What am I doing wrong? Thank you!
The following buildspec worked succesfully:
version: 0.2
env:
secrets-manager:
NPM_TOKEN: "npm-token:npm-token"
phases:
install:
commands:
- npm install
build:
commands:
- npm run build
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
- echo "//registry.npmjs.org/:always-auth=true" >> ~/.npmrc
- npm publish
I'm currently having an issue with my CI Pipeline since it doesn't let me install my private npm dependency.
I'm currently able to push that image to the NPM Registry, but I can't use it in a different project. My pipeline look like this:
trigger:
batch: true
branches:
include:
- main
paths:
exclude:
- README.md
pool:
vmImage: "ubuntu-latest"
parameters:
- name: npm_token_private
displayName: Private Secret
type: string
default: my_secrets
values:
- my_secrets
- name: container_registry
displayName: ContainerRegistry
type: string
default: test01
values:
- test01
- test02
variables:
- group: ${{ parameters.npm_token_private }}
- name: repository
value: QA-Test
- name: containerRegistry
value: ${{parameters.container_registry}}
- name: Tags
value: master
stages:
- stage: Getting_Access_Repo
displayName: Preparing app for deployment
jobs:
- job:
continueOnError: false
steps:
# Gives access to repo
- checkout: self
clean: true
persistCredentials: true
- task: UseNode#1
inputs:
version: '14.x'
- script: npm set //registry.npmjs.org/:_authToken $(npm_token_private)
displayName: "Set Private Registry"
- script: npm i #test/logger
displayName: Installing logger
My issue is the following:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/#test%2flogger - Not found
npm ERR! 404
npm ERR! 404 '#test/logger#^1.0.14' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vsts/.npm/_logs/2022-03-14T19_39_45_779Z-debug.log
##[error]Bash exited with code '1'.
What I don't understand is that I can push a new image to the NPM Registry by using the same npm_token_ptivate. Does someone knows if I have to recreate a new token or what else do I have to do?
In my github project Im trying to automatically create a new version and publish it to NPM whenever something is pushed to the master branch.
The idea
Create a new minor version
Publish the package to NPM
Im using github actions. My workflow file looks like this:
# This workflow will run tests using node and then publish a package to the npm registry 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:
#trigger on every commit to the main branch
push:
branches:
- main
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v1
with:
node-version: 12
- run: npm test
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: git config user.name $GITHUB_ACTOR
- run: git config user.email gh-actions-${GITHUB_ACTOR}#github.com
- run: git remote add gh-origin https://${GITHUB_ACTOR}:${GITHUB_TOKEN}#github.com/${GITHUB_REPOSITORY}.git
- run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
- run: npm version patch
- run: npm publish
- run: git push gh-origin HEAD:master --tags
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
(https://github.com/ether/ep_align/actions/runs/322527776)
I keep getting a 404 error when doing the publish. Which I dont' understand because the package is online here: https://www.npmjs.com/package/ep_align
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/ep_align - Not found
npm ERR! 404
npm ERR! 404 'ep_align#0.2.7' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
This problem is driving me nuts for a few hours now, and I have no idea what it could be.
Any ideas?
it is just an authentication issue with your token.
Have you ever set the access token in your Repository secrets ? (You might want to create environments as well.)
https://docs.npmjs.com/creating-and-viewing-access-tokens
Or it might be an issue with authorization as well. Please check your token type. It should be automation one.
Here is an example from me >
https://github.com/canberksinangil/canberk-playground
Where I have set my token under the repository settings.
Let me know if this helps :)
The NODE_AUTH_TOKEN token is attached to the wrong step, so the npm publish has no authentication. You need:
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
- run: git push gh-origin HEAD:master --tags
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Also, make sure the case of the env variable (npm_token) here matches that in the GitHub actions settings. Environment variables are case senstive.