Getting npm error while deploying a Next.js app on heroku - heroku

I am trying to deploy a Next.js application on heroku, but during project build it gives error "npm ERR! path /tmp/build_e888593abeb04bd0ba3c83c3147db89b/node_modules/websocket"
I found a solution that says to remove the .git folder from the node_modules/websocket directory. But there is not .git folder in the above mentioned directory.
npm ERR! path /tmp/build_e888593abeb04bd0ba3c83c3147db89b/node_modules/websocket
npm ERR! code EISGIT
npm ERR! git /tmp/build_e888593abeb04bd0ba3c83c3147db89b/node_modules/websocket: Appears to be a git repo or submodule.
npm ERR! git /tmp/build_e888593abeb04bd0ba3c83c3147db89b/node_modules/websocket
npm ERR! git Refusing to remove it. Update manually,
npm ERR! git or move it out of the way first.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.mTr1h/_logs/2019-05-08T16_02_03_118Z-debug.log

1) Run heroku run bash to get into a bash terminal where you would have access to your project’s files
2) Then rm -rf node_modules to completely delete the node_modules directory.
3) Exit bash.
4) Run heroku config:set NODE_MODULES_CACHE=false to ensure Heroku doesn’t try to use a cache in rebuilding your node_modules.
If this resolved it, you should set node_modules_cache back to true.

Related

I am getting a compilation error when I try to deploy my Phoenix Elixir app to Heroku

I am very unfamiliar with the deployment process and how to interpret the build log on Heroku. I'm trying to deploy my Phoenix Elixir app and have gone through the process as outlined on https://hexdocs.pm/phoenix/heroku.html. However, I am get the following error in my build logs:
npm ERR! Linux 4.4.0-1062-aws
npm ERR! argv "/tmp/build_cb2fdf13a1883f06eae3f7c5297f7b64/.heroku/node/bin/node" "/tmp/build_cb2fdf13a1883f06eae3f7c5297f7b64/.heroku/node/bin/npm" "run" "deploy"
npm ERR! node v6.9.2
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! # deploy: `webpack --mode production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # deploy script 'webpack --mode production'.
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 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack --mode production
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/build_cb2fdf13a1883f06eae3f7c5297f7b64/assets/npm-debug.log
I've updated to the latest version of node.js and npm as the logs suggested.
Thanks!
The issue isn't with the version of node that you have locally. If you look at the logs it shows that heroku is trying to use node v6.9.2. That is a really old version of node that won't work. You need to use heroku-buildpack-phoenix-static so that you can define the node version the heroku is trying to use. Add the buildpack with the cli:
$ heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
Then create a file phoenix_static_buildpack.config in your project root directory. In that file define the version of node to use:
node_version=12.18.1
This will tell heroku to use that version of node. After that try to redeploy and the issue should be resolved.
If you have more issues then check out the phoenix docs on deploying to heroku. It has a lot of useful information:
https://hexdocs.pm/phoenix/heroku.html

Running Vapor from Homestead failds

I installed Vapor in a brand new Laravel up. When I try to run 'vapor deploy production' I get this error:
Running Command: npm ci && npm run prod && rm -rf node_modules
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/vagrant/.npm/_logs/2019-10-23T21_24_09_128Z-debug.log
In Process.php line 254:
The command "npm ci && npm run prod && rm -rf node_modules" failed.
Exit Code: 1(General error)
Working directory: /home/vagrant/code/sales2/.vapor/build/app
Output:
================
Error Output:
================
npm ERR! cipm can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVers
ion >= 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/vagrant/.npm/_logs/2019-10-23T21_24_09_128Z-debug.log
I sucessfully installed vapor. Created a new project and left the domain setting at default.
You didn't specify what your host operating system was, but I assume it's windows, when you ran "vagrant up" did you do so as administrator?
That said, this is an issue with npm and not Vapor. I'd running the "npm ci && npm run prod && rm -rf node_modules" command ssh'd into your vagrant console and troubleshoot from there.
You may not have configured the node package manager for this project. From your computer and not the homestead if you are using, run this command
<project directory>: npm install
This will create the necessary file.

EPERM error when running npm install global using Git Bash?

If I use Command Prompt and run it as admin, I get no problems.
But when I use Git Bash, for whatever reason, when I try to install anything globally, I get this error:
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Program Files\nodejs\node_modules\.staging
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging'...
When I'm installing packages locally in specific project folders, a plain npm install, it works perfectly. But I've been trying to run npm install -g bower successfully to no avail.
Sure, I can just run cmd as admin, but I was hoping to get to the bottom of this and understand the problem.
I've tried reinstalling Git Bash, reinstalled Node.js, but still didn't make any progress.

Getting error "EACCES: permission denied" when i install cypress

When i try to install cypress using this commnad:
sudo npm install cypress
or
sudo npm install -g cypress
It is giving me this error:
Error: EACCES: permission denied, open '/Users/humac/node_modules/cypress/cypress.zip'
Workaround: sudo npm install --unsafe-perm=true --allow-root cypress
In my case cypress had trouble accessing /root/.cache/Cypress upon npm install:
EACCES: permission denied, mkdir '/root/.cache/Cypress'
I found a relevant issue and ended up setting a custom cache dir:
export CYPRESS_CACHE_FOLDER=/app/.cache
npm install
Try using yarn package manager or downgrading npm to version 7.
For me it worked correctly.
I'm using Jenkins in an alpine linux container with node 16.
stage('Prepare-build') {
steps {
sh 'node --version'
sh 'npm --version'
sh 'ls -p'
sh 'git config --global --add safe.directory "*"'
sh 'yarn install'
}
}
The error I was getting is the following:
npm ERR! code 1
npm ERR! path /home/jenkins/agent/workspace/project/app/project-web-manager/node_modules/cypress
npm ERR! command failed
npm ERR! command sh /tmp/postinstall-716e113e.sh
npm ERR! Cypress cannot write to the cache directory due to file permissions
npm ERR!
npm ERR! See discussion and possible solutions at
npm ERR! https://github.com/cypress-io/cypress/issues/1281
npm ERR!
npm ERR! ----------
npm ERR!
npm ERR! Failed to access /root/.cache/Cypress:
npm ERR!
npm ERR! EACCES: permission denied, mkdir '/root/.cache/Cypress'
npm ERR!
npm ERR! ----------
npm ERR!
npm ERR! Platform: linux-x64 (Alpine Linux - 3.16.1)
npm ERR! Cypress Version: 10.6.0
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-08-18T17_09_27_887Z-debug-0.log
In my same case export the environment variable cypress cache folder did not work as expected, the error was even made mentioned above.
export CYPRESS_CACHE_FOLDER="/home/jenkins/agent/workspace/project/app/.cache"
After clearing my Cypress cache folder with cypress clear cache I ran into this issue as well.
This is what I did:
sudo rm -rf the Cypress folder in your .cache directory
For me I also deleted the Cypress folder in node_modules
Cleaned cache with npm cache clean --force
Installed Cypress with npm install cypress --save-dev
Hope this helps!
In my case I had issues running Cypress on Mac
An unexpected error occurred while verifying the Cypress executable.
----------
Error: EACCES: permission denied, open '/Users/me/Library/Caches/Cypress/9.7.0/binary_state.json'
----------
Platform: darwin-x64 (22.2.0)
Cypress Version: 9.7.0
The easiest think to do is to locate the folder within Finder app, and for both "Cypress" and "9.7.0" folder and adjust the permissions for "everyone" and "staff" to "Read & Write".
Note: You must click on the lock icon and use your mac admin/system password to change the permissions.

Fabric Composer bna build errors

Since moving to v0.10.x, which removed use of 'bnabuild', I'm having trouble trying to build my bna locally using 'npm install'. I'm running HLF V1.0, node v6.9.5, and npm v3.10.10. There's likely something wrong in the model that has changed since moving to v0.10.x but I cannot figure out what it is from the sparse log information. I've added the model file and js to an empty playground, but no errors are uncovered. I even tried opening directory and file permissions.
Error is:
"npm ERR! argv "/Users/guyho/.nvm/versions/node/v6.9.5/bin/node" "/Users/guyho/.nvm/versions/node/v6.9.5/bin/npm" "install"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! petchain-network#0.0.10 prepublish: mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/petchain-network.bna
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the petchain-network#0.0.10 prepublish script 'mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/petchain-network.bna'.
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 petchain-network package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/petchain-network.bna"

Resources