NPM not installing devDependencies on bitbucket pipeline? - npm-install

I'm trying to setup my first Bitbucket pipeline which simply builds my application and deploys it to my FTP server using the following bitbucket-pipelines.yml
image: node:6.9.4
pipelines:
default:
- step:
caches:
- node
script:
- npm install
- npm test
- step:
script:
- npm run build
- node deploy.js
The issue lies in the npm install because when bitbucket tries to run the npm run build command it says that rimraf (a npm package) is not found. rimraf however is listed in my devDependencies, all regular dependencies in my package.json are downloaded correctly.
There is no global variable set by my so the NODE_ENV could not be it right?

I had the same issue with gulp.
Gulp was in devDependencies and also specified in package.json as script but still it said npm ERR! missing script: gulp
The documentation says to install it globally, so there might be a related issue with your package.
https://confluence.atlassian.com/bitbucket/javascript-node-js-with-bitbucket-pipelines-873891287.html

I had this same issue. For me, the problem was that the version of Node on my local development device was different from the version of Node in the bitbucket-pipelines.yml file.
To fix it, I went into bitbucket-pipelines.yml and changed this line:
image: node:10.15.3
to this:
image: node:14.15.0

Related

Unable to run vue application

I created a project using below command,
npm init vue#latest
The project was created like,
vue project setup
After that run below command,
npm install
then run the below command,
npm run dev
But I got the below error,
Error
Package.json File,
package.json
I tried all the way like cleared cache but couldn't helped me. Also reinstalled the node but didn't worked. Also given full permission to the folder.
npm version - 8.7.0
node version - v16.14.2
Can anyone help me?

npm ci can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1

This is the issue that I am facing when running the command npm ci to install dependencies in my GitHub Action file.
I am working on an expo managed app and using GitHub Actions as a CI for triggering builds whenever I push my code to developmemt branch.
Here's my build script:
name: EAS PIPELINE
on:
push:
branches:
- development
workflow_dispatch:
jobs:
build:
name: Install and build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node#v1
with:
node-version: 14.x
- name: Setup Expo
uses: expo/expo-github-action#v6
with:
expo-version: 4.x
token: ${{ secrets.EXPO_TOKEN }}
expo-cache: true
- name: Install dependencies
run: npm ci
- name: Build on EAS
run: EAS_BUILD_AUTOCOMMIT=${{1}} npx eas-cli build --platform all --non-interactive
Here's the issue that I am facing Install dependencies step.
Run npm ci
npm ci
shell: /usr/bin/bash -e {0}
env:
EXPO_TOKEN: ***
npm ERR! cipm can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm#5 or later to generate it, then try again.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-10-28T15_16_06_934Z-debug.log
Error: Process completed with exit code 1.
After a lot of research, I was able to figure out that this happens when you are not using npm install for installing dependencies. In my case, I was only using yarn for the dependencies so I was only having yarn.lock file and no package-lock.json file.
One way to resolve this was using npm install to install the dependencies, then you'll have a package-lock.json file and CI won't throw any error.
And the other way if you only want to use yarn, then you need to update that step in your eas-pipeline.yml file for installing the dependencies.
*****************************************************************************************
- name: Install dependencies
run: |
if [ -e yarn.lock ]; then
yarn install --frozen-lockfile
elif [ -e package-lock.json ]; then
npm ci
else
npm i
fi
***************************************************************************************
As I wasn't able to find any solution on StackOverflow and it is our first go-to place to look for any issue. So, I decided to write this answer here.
Here's the original answer: https://github.com/facebook/docusaurus/issues/2846#issuecomment-691706184
I had a similar error.
`npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
with bunch of missing dependency name following this error.
I would run npm ci locally and it would run successfully. However, it would give me the error above when npm ci is run in the CI pipeline and in my case it was because of the version difference of the Node.js installed in the environment that Jenkins pipeline is running in.
My local Node version was 16.x and in Jenkins container it was 12.x.
Upgrading it fixed.
Old post, but I found this while searching for this same error. In my case I did have a package-lock.json file in my root directory. However, when opening it, I realized that there was a JSON syntax error that slipped in during a previous merge conflict. After running npm i again the file was fixed. The npm ERR! The 'npm ci' command can only install with an existing package-lock.json wasn't a super helpful error in that case.
This same thing happened to me, and I couldn't figure it out for the longest time. It turns out that I had legacy-peer-deps=true set globally, and I had no idea.
This caused my npm install command to alter the package-lock.json in a way that broke the build on our CI server. I reset package-lock.json with the version from master, removed that npm config, and reinstalled. Everything worked fine after that.
For the people who has this issue on AWS Amplify. You might have to run npm install and commit the package-lock.json file, then deploy again.
If you're using pnpm, you install node dependencies via this step:
- name: Install Node.js dependencies
run: |
npm i -g pnpm
pnpm i
After battling with this issue for about 2 days, It's finally deploying successfully to Firebase Functions after deleting package-lock.json from both the src and src/functions folders.
This occurred because the package lock file was not generated with npm, despite the fact that the npm ci requires npm to install the packages.
And because npm requires package-lock.json, we get this error. To fix this error for GitHub actions, this what I did:
- run: yarn install --frozen-lockfile
- run: yarn lint
- run: yarn test:ci
Commit diff:
deleting deploy.json helped me, since the token is updated when overwritten
rm ~/.config/configstore/#vkontakte/vk-miniapps-deploy.json
but I have other services
This happens sometimes because of the version difference of the Node.js installed in the environment that the pipeline is running in.
To fixe this, I ran:
$ firebase init hosting:github
then type Y to set up workflow when asked to.
finally, add "npm i" as one of the scripts to run before deploying like this:
npm i && npm ci && npm run build
I was using npm package manager and migrated to yarn package manager removing package-lock.json file.
I had this configuration in my .circleci/config.yml file
- node/install-packages
changed to
- node/install-packages:
pkg-manager: yarn
In my case the problem were some 'extraneous' packages, concretely local path dependencies. After removing them from package.json the problem was solved.
I got the error message while running npm install instead of npm ci.
On package.json I change this :
"overrides": {
"trim-newlines": "^3.0.1"
},
to : `
"overrides": {
"trim-newlines": "^1.0.0"
}
`
That Work for me successfully.
I had a similar problem deploying to heroku. I simply deleted the existing package-lock.json file and then ran
npm install
Merging the new lock file fixed the deploy.
In my case, I had this error with npm ci while using Yarn. I eventually figured out the version of Node I was using wasn't supported.
I did the following:
node -v to confirm my node version (18.0.1)
nvm use 16.13.0
Delete the node_modules directory
Delete yarn.lock
Run yarn
Run yard add + package names
After this, the error no longer occurred and the app deployed correctly.

How can I set the npm version in gitlab CI?

I have a gitlab pipeline for an Angular project with the image in .gitlab-ci.yml
image: node:16
build:
stage: build
script:
- npm ci
- nodejs -v
- npm -v
- npm run build:prod
- npm doctor
When the pipeline reaches the npm doctor it fails with the following error on npm version:
$ npm doctor
Check Value Recommendation/Notes
npm ping ok
npm -v not ok Use npm v7.24.0
node -v ok current: v16.9.1, recommended: v16.9.1
npm config get registry ok using default registry (https://registry.npmjs.org/)
which git ok /usr/bin/git
Perms check on cached files ok
Perms check on local node_modules ok
Perms check on global node_modules ok
Perms check on local bin folder ok
Perms check on global bin folder ok
Verify cache contents ok verified 1361 tarballs
How can I solve this?
In my machine I have the npm version v7.24.0 and the command succeeds.
Install npm before you do anything else, specifying a version, i.e. npm install npm#version -g.
For completeness, if you can't update the global npm, you can do so locally, by replacing npm with npx npm#latest or npx npm#7.24.0. npx will install npm if it needs to, locally, and then run the local installation.
Lastly you can install locally with npm install npm#latest and then run it with $(npm bin)/npm, but this is what npx is for.
Note that I don't understand why you're running npm doctor after a build. Presumably if you care about npm thining it's set up properly you should run it before the build, so the pipeline fails early.
P.S. I stupidly read 'github' as 'gitlab'. If you were using github I would recommend using
setup-node if only for dependency caching, which can seriously speed up pipelines. I don't know if gitlab does anything similar.

azure devops npm task

I am currently using npm task in my build pipeline in azure devops.
Recently the npm run step started failing with below error. When I manually install the sass and sass-loader the npm run step passes without any error. How can I install the complete modules from pipeline.?
ERROR in Module build failed (from ./node_modules/#angular-devkit/build-angular/node_modules/sass-loader/lib/loader.js):
You can try the following ways to see if the problem can be solved:
Execute the npm install command to install the node-sass (see here) in the pipeline.
npm install -D node-sass
Reconfigure your npm package on the local machine.
Install or upgrade Angular to the latest version.
Check out the source repository to the local machine.
Remove the nose modules and the package lock.
Reinstall the refresh dependencies for your package via the npm isntall command.
Push the changes to the remote repository, then try the pipeline.
I have fixed the issue by adding another step with npm task and passed and argument(sass-loader) to install the sass modules.

Node-sass binding problem in Github-Actions

I'm setting up a GitHub action with following steps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#master
- uses: borales/actions-yarn#master
with:
cmd: install # will run `yarn install` command
- uses: actions/setup-node#master
with:
node-version: '12.x'
- run: npm run build:prod
It crashes on building the app becuase of OS mismatch on Node Sass library
./node_modules/font-awesome-loader/font-awesome.config.js) Module
build failed (from ./node_modules/sass-loader/dist/cjs.js): Error:
Missing binding
/home/runner/work/xxx/xxx/node_modules/node-sass/vendor/linux-x64-72/binding.node
Node Sass could not find a binding for your current environment:
Linux 64-bit with Node.js 12.x
Found bindings for the following environments:
- Linux/musl 64-bit with Node.js 12.x
Running npm rebuild node-sass as a step causes errors since the agent does not have admin permissions.
Any idea why Github-Actions is giving me linux/musl instead of linux?
The issue was with mixing yarn and npm. I was using yarn to install and npm to build. Doing both with yarn solved the problem.