`npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. - Next JS - node.js

I am trying to host my app on heroku and when I deploy it using heroku cli or github
it gives me following error:
ERROR
-----> Installing dependencies
Installing node modules
npm ERR! code EUSAGE
npm ERR!
npm ERR! `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.
npm ERR!
npm ERR! Missing: #babel/core#7.18.9 from lock file
npm ERR! Missing: #ampproject/remapping#2.2.0 from lock file
npm ERR! Missing: #babel/generator#7.18.9 from lock file
npm ERR! Missing: #babel/helper-compilation-targets#7.18.9 from lock file
npm ERR! Missing: #babel/helper-module-transforms#7.18.9 from lock file
npm ERR! Missing: #babel/helpers#7.18.9 from lock file
npm ERR! Missing: #babel/parser#7.18.9 from lock file
npm ERR! Missing: #babel/template#7.18.6 from lock file
npm ERR! Missing: #babel/traverse#7.18.9 from lock file
npm ERR! Missing: gensync#1.0.0-beta.2 from lock file
npm ERR! Missing: json5#2.2.1 from lock file
npm ERR! Missing: #jridgewell/gen-mapping#0.1.1 from lock file
npm ERR! Missing: #jridgewell/trace-mapping#0.3.14 from lock file
npm ERR! Missing: #jridgewell/gen-mapping#0.3.2 from lock file
npm ERR! Missing: jsesc#2.5.2 from lock file
npm ERR! Missing: #babel/compat-data#7.18.8 from lock file
npm ERR! Missing: #babel/helper-validator-option#7.18.6 from lock file
npm ERR! Missing: #babel/helper-environment-visitor#7.18.9 from lock file
npm ERR! Missing: #babel/helper-simple-access#7.18.6 from lock file
npm ERR! Missing: #babel/helper-split-export-declaration#7.18.6 from lock file
npm ERR! Missing: #babel/helper-function-name#7.18.9 from lock file
npm ERR! Missing: #babel/helper-hoist-variables#7.18.6 from lock file
npm ERR! Missing: globals#11.12.0 from lock file
npm ERR! Missing: #jridgewell/set-array#1.1.2 from lock file
npm ERR! Missing: #jridgewell/sourcemap-codec#1.4.14 from lock file
npm ERR! Missing: #jridgewell/resolve-uri#3.1.0 from lock file
npm ERR! Missing: typescript#4.7.4 from lock file
npm ERR!
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [--no-audit] [--foreground-scripts] [--ignore-scripts]
npm ERR! [--script-shell <script-shell>]
npm ERR!
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.wvu98/_logs/2022-07-24T13_15_41_978Z-debug-0.log
-----> Build failed
I tried deleting package-lock.json but it didn't worked. I have also tried npm ci but that too didn't worked for me. I even search on stack overflow but cloud not find similar problem.

npm i use package.json and create package-lock.json, then npm ci use package-lock.json,
so if delete the packeage-lock.json you can't run npm ci, need to run npm i.
If run npm i --legacy-peer-deps must be change npm ci to npm ci --legacy-peer-deps, because my error is this.

Related

How can I successfully deploy firebase functions?

I'm trying to deploy my Firebase functions using the Firebase CLI (firebase deploy --only functions), but I keep getting the following error:
Build failed: npm ERR! code EUSAGE
npm ERR!
npm ERR! `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.
npm ERR!
npm ERR! Missing: #firebase/app-compat#0.2.3 from lock file
npm ERR! Missing: #firebase/app#0.9.3 from lock file
npm ERR! Missing: #firebase/component#0.6.3 from lock file
npm ERR! Missing: #firebase/logger#0.4.0 from lock file
npm ERR! Missing: #firebase/util#1.9.2 from lock file
npm ERR! Missing: #firebase/component#0.6.3 from lock file
npm ERR! Missing: #firebase/logger#0.4.0 from lock file
npm ERR! Missing: #firebase/util#1.9.2 from lock file
npm ERR! Missing: idb#7.0.1 from lock file
npm ERR!
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle]
npm ERR! [-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling]
npm ERR! [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
npm ERR! [--strict-peer-deps] [--no-package-lock] [--foreground-scripts]
npm ERR! [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run]
npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
npm ERR! [-ws|--workspaces] [--include-workspace-root] [--install-links]
npm ERR!
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info
npm ERR! A complete log of this run can be found in:
npm ERR! /www-data-home/.npm/_logs/2023-02-18T13_26_52_861Z-debug-0.log; Error ID: beaf8772
Build failed: npm ERR! code EUSAGE
npm ERR!
npm ERR! `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.
npm ERR!
npm ERR! Missing: #firebase/app-compat#0.2.3 from lock file
npm ERR! Missing: #firebase/app#0.9.3 from lock file
npm ERR! Missing: #firebase/component#0.6.3 from lock file
npm ERR! Missing: #firebase/logger#0.4.0 from lock file
npm ERR! Missing: #firebase/util#1.9.2 from lock file
npm ERR! Missing: #firebase/component#0.6.3 from lock file
npm ERR! Missing: #firebase/logger#0.4.0 from lock file
npm ERR! Missing: #firebase/util#1.9.2 from lock file
npm ERR! Missing: idb#7.0.1 from lock file
npm ERR!
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle]
npm ERR! [-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling]
npm ERR! [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
npm ERR! [--strict-peer-deps] [--no-package-lock] [--foreground-scripts]
npm ERR! [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run]
npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
npm ERR! [-ws|--workspaces] [--include-workspace-root] [--install-links]
npm ERR!
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info
npm ERR! A complete log of this run can be found in:
npm ERR! /www-data-home/.npm/_logs/2023-02-18T13_27_30_745Z-debug-0.log; Error ID: beaf8772
Build failed: npm ERR! code EUSAGE
npm ERR!
npm ERR! `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.
npm ERR!
npm ERR! Missing: #firebase/app-compat#0.2.3 from lock file
npm ERR! Missing: #firebase/app#0.9.3 from lock file
npm ERR! Missing: #firebase/component#0.6.3 from lock file
npm ERR! Missing: #firebase/logger#0.4.0 from lock file
npm ERR! Missing: #firebase/util#1.9.2 from lock file
npm ERR! Missing: #firebase/component#0.6.3 from lock file
npm ERR! Missing: #firebase/logger#0.4.0 from lock file
npm ERR! Missing: #firebase/util#1.9.2 from lock file
npm ERR! Missing: idb#7.0.1 from lock file
npm ERR!
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle]
npm ERR! [-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling]
npm ERR! [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
npm ERR! [--strict-peer-deps] [--no-package-lock] [--foreground-scripts]
npm ERR! [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run]
npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
npm ERR! [-ws|--workspaces] [--include-workspace-root] [--install-links]
npm ERR!
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info
npm ERR! A complete log of this run can be found in:
npm ERR! /www-data-home/.npm/_logs/2023-02-18T13_27_26_236Z-debug-0.log; Error ID: beaf8772
Build failed: npm ERR! code EUSAGE
npm ERR!
npm ERR! `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.
npm ERR!
npm ERR! Missing: #firebase/app-compat#0.2.3 from lock file
npm ERR! Missing: #firebase/app#0.9.3 from lock file
npm ERR! Missing: #firebase/component#0.6.3 from lock file
npm ERR! Missing: #firebase/logger#0.4.0 from lock file
npm ERR! Missing: #firebase/util#1.9.2 from lock file
npm ERR! Missing: #firebase/component#0.6.3 from lock file
npm ERR! Missing: #firebase/logger#0.4.0 from lock file
npm ERR! Missing: #firebase/util#1.9.2 from lock file
npm ERR! Missing: idb#7.0.1 from lock file
npm ERR!
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle]
npm ERR! [-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling]
npm ERR! [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
npm ERR! [--strict-peer-deps] [--no-package-lock] [--foreground-scripts]
npm ERR! [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run]
npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
npm ERR! [-ws|--workspaces] [--include-workspace-root] [--install-links]
npm ERR!
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info
npm ERR! A complete log of this run can be found in:
npm ERR! /www-data-home/.npm/_logs/2023-02-18T13_27_31_642Z-debug-0.log; Error ID: beaf8772
Functions deploy had errors with the following functions:
randomNumberCall(europe-west3)
randomNumberRequest(europe-west3)
stripeCheckout(europe-west3)
stripeCheckoutWithoutDbQueries(europe-west3)
i functions: cleaning up build files...
Error: There was an error deploying functions:
- Error Failed to create function stripeCheckout in region europe-west3
- Error Failed to create function stripeCheckoutWithoutDbQueries in region europe-west3
- Error Failed to create function randomNumberCall in region europe-west3
- Error Failed to create function randomNumberRequest in region europe-west3
Everything works fine when I test the functions with firebase emulators.
Here's the relevant part of my index.js file:
const stripe = require("stripe")(
"sk_test_XXXXXXXX"
);
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp(functions.config().firebase);
exports.stripeCheckout = functions
.region("europe-west3")
.https.onCall(async (data, context) => {
console.log(data);
const session = await stripe.checkout.sessions.create({
payment_method_types: ["card"],
line_items: data.items.map((item) => ({
quantity: 1,
price_data: {
currency: "eur",
unit_amount: item.price * 100,
product_data: {
name: item.summary,
// description: "description!"
images: [item.image]
}
}
})),
mode: "payment",
success_url: "http://localhost:4205/home?action=success",
cancel_url: "http://localhost:4205/home?action=cancel"
});
return session.id;
});
Any ideas on what could be causing this error? I appreciate your help! 🙏🏻
I tried running npm install and npm ci to make sure all dependencies are installed, but it did not work.
I also watched this video and did everything the same way: https://www.youtube.com/watch?v=r0tlQABfm9k&t=1064s&ab_channel=D-I-Ry

I'm trying to deploy my simple typescript app to firebase cloud functions. But I have got this error

Build failed: ...sing: idb#7.0.1 from lock file
npm ERR! Missing: #firebase/app-check-types#0.4.0 from lock file
npm ERR! Missing: selenium-webdriver#4.1.2 from lock file
npm ERR! Missing: #firebase/auth-types#0.11.0 from lock file
npm ERR! Missing: #firebase/webchannel-wrapper#0.6.2 from lock file
npm ERR! Missing: #firebase/firestore-types#2.5.0 from lock file
npm ERR! Missing: #firebase/app-check-interop-types#0.1.0 from lock file
npm ERR! Missing: #firebase/messaging-interop-types#0.1.0 from lock file
npm ERR! Missing: #firebase/functions-types#0.5.0 from lock file
npm ERR! Missing: #firebase/installations-types#0.4.0 from lock file
npm ERR! Missing: #firebase/performance-types#0.1.0 from lock file
npm ERR! Missing: #firebase/remote-config-types#0.2.0 from lock file
npm ERR! Missing: #firebase/storage-types#0.6.0 from lock file
npm ERR! Missing: #grammyjs/types#2.8.2 from lock file
npm ERR! Missing: chokidar#3.5.3 from lock file
npm ERR! Missing: debug#3.2.7 from lock file
npm ERR! Missing: ignore-by-default#1.0.1 from lock file
npm ERR! Missing: pstree.remy#1.1.8 from lock file
npm ERR! Missing: semver#5.7.1 from lock file
npm ERR! Missing: simple-update-notifier#1.0.7 from lock file
npm ERR! Missing: supports-color#5.5.0 from lock file
npm ERR! Missing: touch#3.1.0 from lock file
npm ERR! Missing: undefsafe#2.0.5 from lock file
npm ERR! Missing: anymatch#3.1.2 from lock file
npm ERR! Missing: fsevents#2.3.2 from lock file...
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [--no-audit] [--foreground-scripts] [--ignore-scripts]
npm ERR! [--script-shell <script-shell>]
npm ERR!
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info
npm ERR! A complete log of this run can be found in:
npm ERR! /www-data-home/.npm/_logs/2022-08-22T07_49_29_487Z-debug-0.log; Error ID: beaf8772
Functions deploy had errors with the following functions:
router(us-central1)
i functions: cleaning up build files...
It looks like you have not executed "npm install". After deployment you have to install your dependencies

Getting Errors while creating new Project in Angular , after removing node-modules and package-lock.json, getting run time errors

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: angular-front-end#0.0.0
npm ERR! Found: jasmine-core#3.4.0
npm ERR! node_modules/jasmine-core
npm ERR! dev jasmine-core#"~3.4.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer jasmine-core#">=3.8" from karma-jasmine-html-reporter#1.7.0
npm ERR! node_modules/karma-jasmine-html-reporter
npm ERR! dev karma-jasmine-html-reporter#"^1.4.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\kurum\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\kurum\AppData\Local\npm-cache_logs\2022-06-25T12_48_31_942Z-debug-0.log
Package install failed, see above.
Remove your node_modules folder and package-lock.json first.
Then try this command:
npm install --legacy-peer-deps
This command tells NPM to ignore peer deps and proceed with the installation anyway.

npm ERR! code ENOTEMPTY npm ERR! syscall rename when installing any npm dependency in a Nextjs Project

premium_app[main] $ npm install --save multer
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /home/nyambura/premium/premium_app/node_modules/ansi-regex
npm ERR! dest /home/nyambura/premium/premium_app/node_modules/.ansi-regex-N772AMTl
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/home/nyambura/premium/premium_app/node_modules/ansi-regex' -> '/home/nyambura/premium/premium_app/node_modules/.ansi-regex-N772AMTl'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/nyambura/.npm/_logs/2021-06-25T19_25_58_561Z-debug.log
I'm getting an instance of such an error when I try downloading any npm dependency. I tried updating node and npm in my Ubuntu and refreshing my terminals, but still. I wholly evaded this by switching to yarn for installing the relative dependencies. What could be the problem with my npm?

How to run npm install for EEXIST error

When I do an npm install I get the foll
node_modules \wdpr-grunt-tasks\node_modules\karma\node_modules\socket.io\node_modules\socket. io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-valid ate>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_ modules\node-gyp\bin\node-gyp.js" rebuild
npm WARN optional dep failed, continuing utf-8-validate#1.2.1
npm ERR! EEXIST, npm-cache\56f3dfab--cac he-lodash-3-10-1-package-tgz.lock'
File exists: 56f3dfab--cache-lodash- 3-10-1-package-tgz.lock
Move it away, and try again.
npm ERR! System Windows_NT 6.1.7601
npm ERR! node -v v0.10.36
npm ERR! npm -v 1.4.28
npm ERR! path ... -3-10-1-package-tgz.lock
npm ERR! code EEXIST
npm ERR! errno 47
How do I resolve this issue?
You can try to clean your npm cache with command:
npm cache clean
To make sure, you can delete node_modules folder and install all modules again.

Resources