Bitbucket Pipelines, npm install fails - npm-install

I use a bitbucket pipeline to deploy my develop branch.
Everything work fine so far, but now i have an error in the pipeline :
npm install npm ERR! Unexpected token } in JSON at position 803931 while parsing near '...==" npm ERR! } npm ERR! } npm ERR!
} npm ERR! ' npm ERR! A complete log of this run can be found in: npm
ERR! /root/.npm/_logs/2020-11-05T14_19_12_739Z-debug.log
Here is my pipeline script :
image: node:10.15.3
pipelines:
branches:
develop: # develop branch
- step:
deployment: test
caches:
- node
script:
- npm install
- npm install -g #angular/cli
- npm install -g firebase-tools
- ng build

Related

Can not "npm publish" to internally-hosted npm repository?

I followed Using Nexus 3 as Your Repository – Part 2: npm Packages to set up an internal npm repository.
I'm then able to do this,
$ npm view jsreport dist.tarball
https://registry.npmjs.org/jsreport/-/jsreport-3.0.1.tgz
I have this in my ~/.npmrc file
$ cat ~/.npmrc
//internal_nexus_url:8081/repository/:_authToken=NpmToken.43b77b61-2492-39b8-8150-38555f6b6943
I have this in my /path_to_project/.npmrc file
registry="http://internal_nexus_url:8081/repository/npm-private/_auth=base64_user_pw"
and this in my /path_to_project/package.json file
{
...
"publishConfig": {
"registry": "http://internal_nexus_url:8081/repository/npm-private"
},
...
}
When do an npm publish I get
npm notice === Tarball Details ===
npm notice name: my-package
npm notice version: 2.4.4
npm notice filename: my-package-2.4.4.tgz
npm notice package size: 141.6 MB
npm notice unpacked size: 421.1 MB
npm notice shasum: 09c134ef93ce70e999d62820b5bffc6cf23765f3
npm notice integrity: sha512-X5iqe9DV03MPG[...]TKvNZO4O8ToyQ==
npm notice total files: 17559
npm notice
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in.
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:
npm ERR! /patch/.npm/_logs/2021-11-16T21_48_03_450Z-debug.log
The error file above basically says the same thing. So I follow the instructions, and do
$ npm adduser
$ npm adduser
npm notice Log in on http://internal_nexus_url:8081/repository/exa-npm-private/_auth=base64_user_pw
Username: nexus-user
Password:
Email: (this IS public) nexus#kmha.com
npm ERR! code E401
npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"
npm ERR! A complete log of this run can be found in:
npm ERR! /path/.npm/_logs/2021-11-16T21_52_29_060Z-debug.log
What's preventing me from publishing to my internal npm repo?
UPDATE:
I modified my ~/.npmrc file to include the information on How should I set _auth in .npmrc when using a Nexus https npm registry proxy? to no avail.

GitLab can't publish npm package

I am having issues with publishing my npm package to the project gitlab registry.
Here is the gitlab-ci.yaml script
build_npm_package:
stage: build
image: node:15.4
script:
- yarn install
- yarn run pre-publish
- cd dist
- npm config set #NAME:registry https://gitlab.NAME.ca/api/v4/projects/${CI_PROJECT_ID}/packages/npm/
- npm config set //gitlab.NAME.ca/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken ${CI_JOB_TOKEN}
- npm publish
Running the pipeline, I get the following error
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://gitlab.NAME.ca/api/v4/projects/8/packages/npm/#NAME%2fproject - 404 Not Found
npm ERR! 404
npm ERR! 404 '#NAME/project#1.0.0' 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! /root/.npm/_logs/2021-04-04T23_18_32_289Z-debug.log
Anything helps thanks!

error while running "npm run build" in vue application

I have cloned vue application from git hub(https://github.com/jimmerioles/progressive-weather-app), for automating the deployment in jenkins. Before doing it, i am checking in my ubuntu machine(GCP vm). There i have installed java,nodejs, npm and vuecli. When i execute a command "npm run build" getting the below error. I tried re-installing vuecli, nodejs and npm also., still getting the same error. Kindly let me know how can i fix this.
npm version is "6.2.0", nodejs version is "v14.3.0" and vuecli is a latest one.
root#instance-2:~/weather/src# npm run build
> PWeatherApp#0.1.0 build /root/weather
> vue-cli-service build
sh: 1: vue-cli-service: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! PWeatherApp#0.1.0 build: `vue-cli-service build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the PWeatherApp#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-05-23T18_32_20_092Z-debug.log
its may help you:
npm install -g #vue/cli
# OR
yarn global add #vue/cli

Using elm-test in a git hub action

I want to use the an git hub action to test and build my elm package whenever a commit is pushed to the master branch for this my action .yml file looks like this
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Setup Elm environment
uses: JorelAli/setup-elm#v1
with:
# Version of Elm to use. E.g. 0.19.1
elm-version: 0.19.1
- run: |
sudo npm install -g elm-test # this fails
elm-test
elm make
for testing I want to use elm-test which can be installed via npm but the command sudo npm install -g elm-test fails with
/usr/local/bin/elm-test -> /usr/local/lib/node_modules/elm-test/bin/elm-test
> elmi-to-json#1.3.0 install /usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json
> binwrap-install
ERR Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json/unpacked_bin'
at Object.mkdirSync (fs.js:823:3)
at /usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:46:10
at new Promise (<anonymous>)
at untgz (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:21:10)
at binstall (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:11:12)
at install (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/install.js:20:10)
at Object.install (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/index.js:14:14)
at Object.<anonymous> (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/bin/binwrap-install:18:9)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11 {
errno: -13,
syscall: 'mkdir',
code: 'EACCES',
path: '/usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json/unpacked_bin'
}
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.1.2 (node_modules/elm-test/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! elmi-to-json#1.3.0 install: `binwrap-install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the elmi-to-json#1.3.0 install 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! /home/runner/.npm/_logs/2020-02-03T17_50_06_232Z-debug.log
Any advice on how to install elm-test inside a git hub action?
Edit:
Without the sudo the error becomes
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! stack: "Error: EACCES: permission denied, access '/usr/local/lib/node_modules'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2020-02-04T13_41_34_534Z-debug.log
Thanks to #toastal comment I found another solution. That is to set up a package.json file using npm and then adding elm-test as a dependency with the command
npm install -D elm-test
also you might want to add node_modules to your .gitignore to ignore npms installation folder.
Then in the yml file you can just run the command npm install and elm-test gets installed.
Then you can call it with
./node_modules/elm-test/bin/elm-test
My yml file now looks like this
name: Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Setup Elm environment
uses: JorelAli/setup-elm#v1
with:
# Version of Elm to use. E.g. 0.19.1
elm-version: 0.19.1
- name: install npm dependencies
run: npm install
- name: Test
run: ./node_modules/elm-test/bin/elm-test
- name: check documentation
run: |
elm make --docs=docs.json
rm docs.json
Thanks to #glennsl I found a solution: specifying where npm installs package globally.
Since the runner that runs the action has no access to the /usr/local/lib npm can't install anything on a global level.
The solution (as described here) is to create a folder as a "global" installation folder and configuring npm to use it. It is also necessary to add the new folder to the PATH environment variable.
So my yml file now looks like this
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Setup Elm environment
uses: JorelAli/setup-elm#v1
with:
# Version of Elm to use. E.g. 0.19.1
elm-version: 0.19.1
- run: |
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
PATH=~/.npm-global/bin:$PATH
npm install -g elm-test
elm-test
elm make

Gitlab-ci-multi-runner continues if npm publish fails

I use gitlab-ci-multi-runner to publish our artifact to our own npm registry. This is the .gitlab-ci.yml file:
publish-continuous:
type: publish
script:
- npm install
- npm run test
- npm run build
- npm publish --registry $env:NPM_REGISTRY_URL
Sometimes the npm publish fails. This is the output:
$ npm publish --registry $env:NPM_REGISTRY_URL
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\SomeUser\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "publish" "--registry" "https://ourownregistry"
npm ERR! node v4.2.6
npm ERR! npm v3.6.0
npm ERR! code ENEEDAUTH
I would expect that the gitlab-ci-multi-runner stops because the job fails. But it doesn't! It reports Build succeeded.
Anyone knows how I can make the build fail if npm publish fails?
Fixed it by updating to the latest NPM. v3.8.1 fixed the issue. Now it returns a -1 exit code and the build fails.