I've been going through the nightmare that is trying to get lerna to publish in my ci pipeline.
I've managed to have the scripts pull from git to check tags and I've found the withNPM pipeline plugin. Because I'm using lerna to publish multiple packages I have to move the .npmrc file that the plugin creates in the workspace to the root of the the home directory so that all packages can access it.
The NPM plugin uses the jenkins config file to create the .npmrc file. Which looks like this:
//registry.npmjs.com/:_authToken=TOKEN
Here is what I have in my Jenkins pipeline.
stage('lerna publish') {
steps {
withCredentials([sshUserPrivateKey(credentialsId: 'cb8acd82-3a50-4a94-9d5f-44b04856e6fd', keyFileVariable: 'GITHUB_KEY')]) {
sh 'echo ssh -i $GITHUB_KEY -l git -o StrictHostKeyChecking=no \\"\\$#\\" > ./run_ssh.sh'
sh 'chmod +x ./run_ssh.sh'
withEnv(['GIT_SSH=./run_ssh.sh']) {
withNPM(npmrcConfig: 'da4e5199-b04b-41b6-a03f-dfbcc344f701') {
sh "rm -rf ~/.npmrc"
sh 'mv ./.npmrc ~/.npmrc'
sh 'npm config set registry https://registry.npmjs.com/'
sh 'git config --global user.email "thomas#reggi.com"'
sh 'git config --global user.name "reggi"'
sh 'git checkout master'
sh 'git pull origin master --force'
sh 'npm run lerna-publish'
}
}
}
}
}
Here's the error:
lerna info auto-confirmed
lerna info publish Publishing packages to npm...
lerna ERR! npm publish --ignore-scripts exited 1 in '#reggi/help.filter-until'
lerna ERR! npm publish --ignore-scripts stderr:
npm notice
npm notice package: #reggi/help.filter-until#0.0.20
npm notice === Tarball Contents ===
npm notice 1.5kB package.json
npm notice 609B index.build.js
npm notice === Tarball Details ===
npm notice name: #reggi/help.filter-until
npm notice version: 0.0.20
npm notice package size: 997 B
npm notice unpacked size: 2.1 kB
npm notice shasum: a6db6d4dc02f05548c22fe2e034832ac02252633
npm notice integrity: sha512-6oAFaXqZMREsh[...]GnMcnIxXUBINg==
npm notice total files: 2
npm notice
npm ERR! code ENEEDAUTH
npm ERR! need auth auth required for publishing
npm ERR! need auth You need to authorize this machine using `npm adduser`
I found I wasn't being consistent with the urls above and changed them both to .com and now I'm getting this issue:
lerna info auto-confirmed
lerna info publish Publishing packages to npm...
lerna ERR! npm publish --ignore-scripts exited 1 in '#reggi/help.filter-until'
lerna ERR! npm publish --ignore-scripts stderr:
npm notice
npm notice package: #reggi/help.filter-until#0.0.23
npm notice === Tarball Contents ===
npm notice 1.5kB package.json
npm notice 609B index.build.js
npm notice === Tarball Details ===
npm notice name: #reggi/help.filter-until
npm notice version: 0.0.23
npm notice package size: 1.0 kB
npm notice unpacked size: 2.1 kB
npm notice shasum: 60ee325b219abdae06a75cfe45bc66096f715187
npm notice integrity: sha512-o4ahyOWAsUk3j[...]O/3MH2Tpv1tOQ==
npm notice total files: 2
npm notice
npm ERR! publish Failed PUT 404
npm ERR! code E404
npm ERR! 404 Not found : #reggi/help.filter-until
npm ERR! 404
npm ERR! 404 '#reggi/help.filter-until' 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.
I have the token setting using the .org domain and the registry set to the .com domain. :(
Related
I tried to publish in registry.npmjs.org/ with gitlab ci, but instead of publish, i get an error
I tried what this page says https://webbureaucrat.gitlab.io/posts/continuously-deploying-an-npm-package-with-gitlab-ci-cd/
with this gitlab-ci.yml file
image: node:latest
stages:
- deploy
deploy:
stage: deploy
script:
- echo "//registry.npmjs.org/:_authToken=${NPMJS_TOKEN}" > .npmrc
- npm publish
But I get the next error
npm notice
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`
npm ERR! A complete log of this run can be found in:\
I tried to change by this but I have the same output
- npm config set //registry.npmjs.org/:_authToken ${NPMJS_TOKEN}
I thought I would fixed something when i did this because the error message changes
- npm config set //registry.npmjs.org/:_authToken ${NPMJS_TOKEN}
npm notice
npm notice Publishing to https://registry.npmjs.org/
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/xxxx - Not found
npm ERR! 404
npm ERR! 404 'xxxx#1.0.0' is not in this registry.
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:
But I couldn't go any further than here, the funny thing is if i go to this link https://registry.npmjs.org/xxxx after i published local, this results something by HTTP get by browser, but still show the same message, even if I increase the version
The only way i can have same error doing a local publish was doing npm publish after i delete the package, i had to change the package name to publish again (this doesn't work in gitlab)
The following chain of events had occured.
The Angular website application was pretty outdated, possibly v3 and was upgraded to 8.2.8, couldnt go all the way due to a dependency on mdbbootstrap which would require a rewrite in many places, made a change and the pipeline and check completed.
Coming back from another project i ran into this problem Angular project produces javascript error "core.js:23018 Uncaught TypeError: Cannot read properties of undefined (reading 'id')", which was solved by npm -ci
Now after making my current changes, and sending off to gitlab pipeline, the following errors occur
npm ERR! While resolving: angular-date-value-accessor#0.0.1
npm ERR! Found: #angular/core#8.2.14
npm ERR! node_modules/#angular/core
npm ERR! #angular/core#"~8.2.8" from the root project
npm ERR! peer #angular/core#"8.2.14" from #angular/animations#8.2.14
npm ERR! node_modules/#angular/animations
npm ERR! #angular/animations#"~8.2.8" from the root project
npm ERR! peer #angular/animations#">=6.0.0 <9.0.0" from angular-calendar#0.26.11
npm ERR! node_modules/angular-calendar
npm ERR! angular-calendar#"^0.26.11" from the root project
npm ERR! 23 more (#angular/common, #angular/forms, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #angular/core#"^2.0.0" from angular-date-value-accessor#0.0.1
npm ERR! node_modules/angular-date-value-accessor
npm ERR! angular-date-value-accessor#"0.0.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: #angular/core#2.4.10
npm ERR! node_modules/#angular/core
npm ERR! peer #angular/core#"^2.0.0" from angular-date-value-accessor#0.0.1
npm ERR! node_modules/angular-date-value-accessor
npm ERR! angular-date-value-accessor#"0.0.1" from the root project
this is the gitlab-ci yaml
stage: build_staging
image: node:lts
script:
- grep -rli '%COMMIT_HASH%' * | xargs -i# sed -i "s/%COMMIT_HASH%/$CI_COMMIT_SHORT_SHA/g" #
- cd src/Web
- npm install
- npm run buildstaging
artifacts:
paths:
- src/Web/dist/
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
only:
refs:
- develop
Deploy Web Staging:
stage: deploy_staging
image: xueshanf/awscli
script:
- cd src/Web
- aws s3 sync ./dist s3://$STAGING_BUCKET_NAME/ --delete
- echo "Invalidate index.html"
- aws cloudfront create-invalidation --distribution-id $STAGING_DISTRIBUTION_ID --paths /index.html
only:
refs:
- develop
(fyi its the build_staging that is the problem)
I am assuming what was fixed on my local machine is now no longer valid for npm install on npm:lts
What would be the proper course of direction, is it as simple as
npm ci( a very demanding operation) instead of npm install ? or git clean ?
I also noticed, although everything works fine locally
in package.json and lock it has
"#angular/core": "~8.2.8",
but in my node_modules it has 8.2.14 in /#angular/core/
after running npm ci
ok here is what i did to get it working. This would not be a problem if ng commands would work so it could auto resolve dependency problems. Each problem gitlab complained about i manually uninstalled and installed to see the error, and its dependency issue. I upgraded either the component or dependency. until all were gone. Some components had to go completely, but none required a re-code of any usage (i think so far, it hasnt been fully tested).
Now when i finally resolved all these issues, i would get errors such as this
npm ERR! path /builds/0/WebSites/customerportal/CustomerPortal/src/Web/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/local/bin/node /builds/0/WebSites/customerportal/CustomerPortal/src/Web/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
allot more all pointing to gyp, and some problem with python version.
I changed the version of the image to Node:14 in the yaml file, and the building stage would complete. Also, the deploy stage would complete, (but the C# api layers time out on warning: 8 tasks failed to start
By mistake, I have deleted an NPM Package from Azure Artifact Feed and then deleted it from Recyclebin also. Now while trying to push the NPM package back to Azure Artifact Feed, I am getting the below error message. How do I push the same package again to Artifact Feed?
> npm --registry https://pkgs.dev.azure.com/maryodavid0305/Platform/_packaging/test/npm/registry/ publish jdmessenger-1.0.0.tgz
npm notice
npm notice package: #jd-libs/jdmessenger#1.0.0
npm notice === Tarball Contents ===
npm notice 2.1kB dist/cjs/events.js
npm notice 938B dist/esm/events.js
npm notice 5.2kB dist/cjs/executor.js
npm notice 4.0kB dist/esm/executor.js
npm notice 712B dist/cjs/index.js
npm notice 87B dist/esm/index.js
npm notice 1.9kB package.json
npm notice 1.0kB dist/cjs/events.js.map
npm notice 975B dist/esm/events.js.map
npm notice 3.4kB dist/cjs/executor.js.map
npm notice 3.4kB dist/esm/executor.js.map
npm notice 141B dist/cjs/index.js.map
npm notice 145B dist/esm/index.js.map
npm notice 602B README.md
npm notice 1.0kB dist/cjs/events.d.ts
npm notice 1.0kB dist/esm/events.d.ts
npm notice 1.9kB src/tests/events.spec.ts
npm notice 1.7kB src/events.ts
npm notice 1.3kB dist/cjs/executor.d.ts
npm notice 1.3kB dist/esm/executor.d.ts
npm notice 5.2kB src/tests/executor.spec.ts
npm notice 5.8kB src/executor.ts
npm notice 54B dist/cjs/index.d.ts
npm notice 54B dist/esm/index.d.ts
npm notice 54B src/index.ts
npm notice === Tarball Details ===
npm notice name: #jd-libs/jdmessenger
npm notice version: 1.0.0
npm notice package size: 8.8 kB
npm notice unpacked size: 44.1 kB
npm notice shasum: 294b8c616c6a846d1b5ef72fca3df4412c1830d4
npm notice integrity: sha512-3Q3rsjeOMUms7[...]NVf6QC56tHDyw==
npm notice total files: 25
npm notice
npm ERR! code E403
npm ERR! 403 403 Forbidden - The version 1.0.0 of #jd-libs/jdmessenger has been deleted. It cannot be restored or pushed. (DevOps Activity ID: 54385895-A886-4BB4-A948-AF65CEE0F8A7) - PUT https://pkgs.dev.azure.com/maryodavid0305/Platform/_packaging/test/npm/registry/#jd-libs%2fjdmessenger - The version 1.0.0 of #jd-libs/jdmessenger has been deleted. It cannot be restored or pushed.
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\maryo\AppData\Roaming\npm-cache\_logs\2022-02-09T09_50_24_857Z-debug.log
The only way to do this, as I know, is pushing another version.
If possible, upgrade version number, i.e. 1.0.1, and push it.
After npm run deploy i have errors like above
Repo on Github
I am trying to deploy my react-app on gh-pages on Github (create-react-app)
'gh-pages' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-world-4#0.1.0 deploy: `npm run build&&gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-world-4#0.1.0 deploy script 'npm run build&&gh-page
s -d build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the hello-world-4 package
,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run build&&gh-pages -d build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs hello-world-4
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls hello-world-4
npm ERR! There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jan\AppData\Roaming\npm-cache\_logs\2017-05-12T17_55_00_56
9Z-debug.log
So I run this command npm install --save gh-pages
like below
After that I run the command npm run deploy
My code published successfully like below.
For more details just follow this link by Facebook which is given below.
(https://facebook.github.io/create-react-app/docs/deployment#github-pages-https-pagesgithubcom)
I hope your issue will be resolved. In case of error please reply.
please install gh-pages and it ready to go
To install
npm install gh-pages
to deploy
add this to package.json
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
and then this
npm run deploy
gh pages stands for GitHub Pages. It is simply a way to deploy a website via a github repo. Basically, NPM is yelling because when it attempts to run the command deploy, there is not link or reference to the line
$npm run build&&gh-pages -d build
You need make sure that gh-pages -d build is defined. A place to start would be running gh-pages --man or gh-pages --help
I facing the same problem I do the following command before
git push
not working. After
git push
I do the same command it works correctly.
npm install gh-pages
and deploy
npm run deploy
I have an express project that accesses some common node code that I keep in a private repository in github. I have a line like the following in my package.json file
git+ssh://git#github.com:MYGITHUBACCT/MYPROJECT.git#master
When I run npm install, everything works correctly and it pulls my common code from the private repo and places it in my node_modules directory. However, when I run npm update, it fails on my private repo and displays the following:
npm ERR! 404 'MYPROJECT' 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 12.2.0
npm ERR! command "node" "/usr/local/bin/npm" "update"
npm ERR! cwd /Users/ginnyd/dev/gg-web
npm ERR! node -v v0.8.16
npm ERR! npm -v 1.1.69
npm ERR! code E404
Is there anything special I need to do in the package.json so that I can run the update and have it pull from GitHub?
Thanks
Ginny
Apparently, this is still an open issue with npm.
Meanwhile, to update git dependencies, you have to remove them first and then doing an npm install.
rm -rf node_modules/MYPROJECT
npm install
This have fixed in npm, please upgrade to npm >= 1.3.10
Sample usage
"dependencies": {
"thing": "git://github.com/myGitHubRepo/repo.js.git#56477cb",
}
Some day later
"dependencies": {
"thing": "git://github.com/myGitHubRepo/repo.js.git#67f90b5",
}
Then npm install again and you will get new ref!
If your "myGitHubRepo/repo.js" is a private package you should set "private": true there to ensure it doesn't get accidentally published to npm registry