I have 2 repository. One is main, second is dependency package.
In main project in .gitlab-ci.yml I have:
install_dependency:
stage: install-dep
before_script:
- npm config set strict-ssl false
- ls -la
script:
- git config --global http.sslverify false
- npm config set #my-package:registry https://${TOKEN_USERNAME}:${TOKEN_PASSWORD}#HOST/PACKAGE/PACKAGE.git
- npm i git+https://${TOKEN_USERNAME}:${TOKEN_PASSWORD}#HOST/react.git#master
Dependecy have package.json that should install using `npm -i" as dependecy:
package/mypackage: git+https://${TOKEN_USERNAME}:${TOKEN_PASSWORD}#HOST/react.git#master
A problem is that CI did not recognize path:
$ npm i git+https://${TOKEN_USERNAME}:${TOKEN_PASSWORD}#HOST/react.git#master
npm ERR! prepareGitDep 2> npm WARN install Usage of the `--dev` option is deprecated. Use `--only=dev` instead.
npm ERR! prepareGitDep npm WARN tar ENOENT: no such file or directory, open '/root/.npm/_cacache/tmp/git-clone-7b8b3c6a/node_modules/.staging/uglify-js-ce069d2e/lib/compress.js'
Use self-hosted https://verdaccio.org/ to publish NPM package solves that issue.
For publishing into Gitlab it should upgrade Gitlab package (silver ediiton).
Related
I'm setting up a GitHub action to automatically lint and test every commit. Unfortunately, the action always fails when npm is installing the dependencies.
In short, I think something's messed up with the package-lock.json and I need to regenerate it, somehow. Any ideas?
The error
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/fsevents/-/fsevents-2.2.3.tgz
npm ERR! 404
npm ERR! 404 'fsevents#2.2.1' 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/runner/.npm/_logs/2021-01-08T07_29_59_535Z-debug.log
I believe that's a result of this section of the package-lock.json
"fsevents": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.2.3.tgz",
"integrity": "sha512-bTLYHSeC0UH/EFXS9KqWnXuOl/wHK5Z/d+ghd5AsFMYN7wIGkUCOJyzy88+wJKkZPGON8u4Z9f6U4FdgURE9qA==",
"dev": true,
"optional": true
}
Notice how the URL is different than the version number. Fsevents never had a v2.2.3, only v2.2.2.
Fsevents is not a direct dependency of this project (i.e., it's not in the package.json).
Debug steps
I've tried:
npm update
npm audit fix
deleting the package-lock.json, then npm install
npm install --package-lock
manually editing the package-lock.json, but it just reverts back after an npm install
on my computer (macOS Big Sur, Intel), I did rm -rf node_modules && npm install, but I have any issues installing or running the tests
on my computer, I tried npm ci just like the action, no error or issues
The GitHub action
In case it makes a difference, here's the GitHub action:
name: Continuous integration
on: [push]
jobs:
test-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v1
with:
node-version: 14
- run: npm ci
- run: npm run lint
- run: npm run test
The error occurs on the npm ci step.
[Update]: I also tried the Github Action on macOS with runs-on: macos-latest. Same error.
Turns out I needed to both delete the node_modules and package-lock.json. Doing only one of the two didn't work.
rm -rm node_modules
rm package-lock.json
npm i
I have many package.json files in my application. Each module has its own dependencies written in its own package.json. How can I install all dependencies at once?
I tried to run npm install and it installed dependencies only according to package.json in directory where i ran npm install
You can use npm prefix parameter:
npm i --prefix <nested_dir_name>
For the following project structure:
- client
- package.json
- server
- package.json
- package.json
You should use the following command to install the dependencies in all folders:
npm i && npm i --prefix client && npm i --prefix server
In the web3 version 1.x docs: https://web3js.readthedocs.io/en/1.0/getting-started.html it says to install web 3 using
npm install web3
but this installs version 0.2x.00.
so what should I do?
Install from the github repo using the 1.0 branch directly:
npm install git+https://github.com/ethereum/web3.js.git\#1.0ES6
EDIT: Adding example install into a new project directory.
$ npm install git+https://github.com/ethereum/web3.js.git\#1.0ES6
> web3#1.0.0-beta.24 postinstall C:\cygwin\home\adamk\eth\web3-1.0\node_modules\web3
> lerna bootstrap
lerna info version 2.9.0
lerna info Bootstrapping 20 packages
lerna info lifecycle preinstall
lerna info Installing external dependencies
lerna info Symlinking packages and binaries
lerna info lifecycle postinstall
lerna info lifecycle prepublish
lerna info lifecycle prepare
lerna success Bootstrapped 20 packages
npm WARN saveError ENOENT: no such file or directory, open 'C:\cygwin\home\adamk\eth\web3-1.0\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'C:\cygwin\home\adamk\eth\web3-1.0\package.json'
npm WARN web3-1.0 No description
npm WARN web3-1.0 No repository field.
npm WARN web3-1.0 No README data
npm WARN web3-1.0 No license field.
+ web3#1.0.0-beta.24
added 1 package in 65.026s
When I download a project from my repo with a package.json in its root, which command is the right one to use npm install or npm install restore?
The behaviour of npm install is
npm install without any argument will install all packages found in package.json in node_modules folder.
npm install <package_name> will install package_name. In your case will download restore package and will save it in node_modules folder. (https://www.npmjs.com/package/restore)
Just type:
npm i
From help:
>npm i -h
npm install (with no args, in package dir)
npm install [<#scope>/]<pkg>
npm install [<#scope>/]<pkg>#<tag>
npm install [<#scope>/]<pkg>#<version>
npm install [<#scope>/]<pkg>#<version range>
npm install <folder>
npm install <tarball file>
npm install <tarball url>
npm install <git:// url>
npm install <github username>/<github project>
aliases: i, isntall, add
common options: [--save-prod|--save-dev|--save-optional] [--save-exact] [--no-save]
I am using gitlab-ci to for my CI/CD to publish a NPM module to a registry. Following is my gitlab-ci.yml file
image: docker:latest
variables:
DOCKER_DRIVER: overlay2
services:
- docker:dind
cache:
untracked: true
key: "$CI_COMMIT_REF_NAME"
paths:
- node_modules/
stages:
- setup
job-setup:
stage: setup
tags:
- angular
image: node:alpine
except:
- tags
script:
- npm set registry https://registry.npmjs.org
- npm i
- cp .npmrc ~/.npmrc
- npm publish --registry https://registry.npmjs.org
I get the following warning messages on the publish command. The module gets published but the /dist folder within the module is missing.
npm WARN prepublish-on-install As of npm#5, `prepublish` scripts are deprecated.
npm WARN prepublish-on-install Use `prepare` for build steps and `prepublishOnly` for upload-only.
npm WARN prepublish-on-install See the deprecation note in `npm help scripts` for more information.
npm WARN lifecycle my_npm_module#1.1.1~prepublish: cannot run in wd %s %s (wd=%s) my_npm_module#1.1.1 npm run build /builds/code/my_npm_module
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
NPM is having issues with running in the 'working directory' (wd) and I am not sure how to solve it. I am running gitlab-ci on Centos.
npm is refusing to run the build scripts from your package.json because it's running as root. Add
echo "unsafe-perm = true" >> ~/.npmrc
to your gitlab-ci.yml script before invoking npm.