Using a fork npm package in docker image - npm

I am using a pretty cool npm package react-awesome-query-builder inside one of my docker compose image. However, there is a small bug that I was able to find an answer for. I forked the package, made the change and pushed the changes up to my fork. I then tried modify my package.json to use my forked package
"react-awesome-query-builder": "billtlee/react-awesome-query-builder#Material-UI-subgroups",
However, when I try to docker-compose build the package, I am getting the following error:
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -2
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://git#github.com/billtlee/react-awesome-query-builder.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
I also tried to use the package on codesandbox.io, but it was complaining as well. Does anyone know what I am doing wrong?
Thanks in advance!

Figured out that it's because of git. I added
RUN apk update
RUN apk add git
into my dockerfile and it's now working. Still want to know if anyone knows how to use a forked package in codepen.

I ran into the same issue when using apt-get. I had to use the -y flag as well as I was getting this error when building the docker container without the -y flag link:
#5 3.783 After this operation, 43.1 MB of additional disk space will be used.
#5 3.783 Do you want to continue? [Y/n] Abort.
------
executor failed running [/bin/sh -c apt-get update && apt-get install git libxml2-utils]: exit code: 1
So:
RUN \
apt-get update && \
apt-get install -y git

Related

npm link issue related to Homebrew

So I'm trying to use npm link to make some binaries available globally as CLI commands.
My package.json looks like this:
{
"bin": {
"foo": "./relative/path/to/foo",
},
...
When I run npm link, I get the following error:
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /opt/homebrew/lib/node_modules/foo/relative/path/to/foo
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/opt/homebrew/lib/node_modules/foo/relative/path/to/foo'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
So it seems it's tryiung to link the file from a homebrew install directory for some reason.
I've tried re-installing npm from the installer at nodejs.org, but it seems like npm is still coming from homebrew for some reason:
% which node
/usr/local/bin/node
% which npm
/opt/homebrew/bin/npm
But there does not seem to be a brew formula for npm. Where is this homebrew npm coming from and how do I get rid of it?
rm -rf /opt/homebrew/bin/npm
The above did the trick for me after uninstalling node with brew and then re-installing with nvm (without brew).

How to update npm in Laravel Sail

I am currently using Laravel 8.48.2 with the Sail package. I set Sail up and running its image through Docker Desktop while using WSL 2 with a Ubuntu distro on Windows. All seems to be working fine.
After I ran sail npm install, the packages were installed successfully, but I received the following message:
npm notice New minor version of npm available! 7.18.1 -> 7.19.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.19.0
npm notice Run npm install -g npm#7.19.0 to update!
Therefore, I tried running sail npm install -g npm#7.19.0 which gave me the following message:
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/lib/node_modules/npm
npm ERR! dest /usr/lib/node_modules/.npm-qUIFSsiV
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm-qUIFSsiV'
npm ERR! [Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm-qUIFSsiV'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/lib/node_modules/npm',
npm ERR! dest: '/usr/lib/node_modules/.npm-qUIFSsiV'
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/sail/.npm/_logs/2021-06-26T15_27_02_291Z-debug.log
How can I update the NPM version on Sail?
Thank you in advance.
Current working method:
sail root-shell
npm install -g npm#latest
Looking at your log it seems the user you run as has insufficient permission on the folder /usr/lib/node_modules/. So what you might try is to log in to the container with docker-compose exec laravel.test bash and use chown -R user:group /usr/lib/node_modules/ with the current user and group (found by whoami). Or chmod the folder to have more looser permission overall on this folder.
Thanks to #online Thomas (https://stackoverflow.com/a/68173952/14508436), in order to resolve my issue, I followed these steps:
Within my Laravel project's directory, I ran this command... docker-compose exec laravel.test bash, which points you to the docker's server (or something like that), directly on your project's directory.
I ran this command... npm install -g npm#7.19.0 which updated npm to a newer version without any issues.
I tried the chown and chmod commands as suggested by #online Thomas, but in vain. I still couldn't use the sail npm install -g npm#7.19.0 command outside of the docker's server.

Missing write access error on nativescript install

When I attempt to install nativescrtipt by running npm i -g nativescript, I receive the following error:
npm WARN checkPermissions Missing write access to
/usr/local/lib/node_modules/nativescript
npm ERR! path /usr/local/lib/node_modules/nativescript
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access
'/usr/local/lib/node_modules/nativescript'
npm ERR! enoent This is related to npm not being able to find a
file.
I have tried to run the command as sudo and receive the same result. I also attempted to add write permission to the node_modules directory.
I am running node v10.6.0 on macOS High Sierra.
Add sudo command to allow you run the program with security privilege
sudo npm i -g nativescript
I followed this link: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally to resolve the issue.
I installed nvm and updated to the latest version of node. Then, the command npm i -g nativescript successfully installed the nativescript-cli.
The issue does not appear to be coming from nativescript, but an issue with my node installation.
Run the following command sudo npm i -g nativescript
This will forcefully with security permission install the missing scripts to run the npm command again with no bugs or warnings

gulp-sass npm ERR! Failed at the node-sass#4.9.0 install script

Im trying to install gulp-sass from terminal window in visual studio code.
other dependencies like autoprefixer, concat etc install without a problem, but gulp-sass keeps giving me this error.
> node-sass#4.9.0 install /usr/local/lib/node_modules/node-sass
> node scripts/install.js
sh: node: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! node-sass#4.9.0 install: `node scripts/install.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the node-sass#4.9.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Im running VSC on a mac.
Any help please? I am completely new at all this btw, no programming background, just front end dev.
Thanks a lot
I have the same problem. And I found this solution:
sudo npm install -g node-sass#4.5.3 --unsafe-perm = true --allow-root
I just changed part of the code:
sudo npm install gulp-sass --unsafe-perm = true --allow-root
It worked for me.
[npm install -g node-sass#4.5.3 --unsafe-perm=true --allow-root]
This one did work for me to install the package but it failed again when I start the application
I tried with the [yarn install] instead of [npm install]
The app started successfully.
I get the same solution as you. and I tried searching on the internet and I found here http://relaxitblog.com/?p=611
then after that I installed: sudo npm install gulp-sass
after that: npm audit fix
success

npm install error Failed at the phantomjs#1.9.12 install script

I am getting this error when am trying to do npm install...am struck with this nearly for 4 days...please can someone help me out...
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "c:\\Program Files\\nodejs\\node.exe" "c:\\Users\\Username\\AppData\\Roaming\\npm\\node_modules\\n pm\\bin\\npm-cli.js" "install"
npm ERR! node v0.10.33
npm ERR! npm v2.1.5
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! phantomjs#1.9.12 install: `node install.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the phantomjs#1.9.12 install script.
npm ERR! This is most likely a problem with the phantomjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls phantomjs
npm ERR! There is likely additional logging output above.
I had the exact same issue on Windows. To fix it, I took the following steps:
Install the latest version of phantomjs (currently, phantomjs-1.9.8-windows) locally, by downloading and unziping. I had a previous version which was not compatible with phantomjs npm package.
Update your environment variable to point to latest version of phantomjs.exe (PHANTOMJS_HOME).
Exit and restart windows prompt or shell to recognize variable.
Now, npm install or specifically, npm install phantomjs#1.9.12 should work correctly.
You can test your local phantomjs executable install with a where phantomjs and phantomjs -v from a git bash shell or command prompt.
I am working under a corporate proxy, So it was blocking npm to download 'phantom' from https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-windows.zip
So, I fixed it in the following way...
Download 'phantomjs-2.1.1-windows.zip' file from the above link directly.
Copy and paste it to 'C:\Users\user_name\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip'
Now, just do 'npm install', it will work like a charm.
Read the error and find the correct version of phantomjs (might be 1.9.12 or 2.1.1 ).
Find the appropriate file in the maven repo.
Download the zip file and copy the same zip file to C:\Users\User_ID\AppData\Local\Temp\phantomjs\ and paste it (in zip format).
Set or create an environment variable PHANTOMJS_HOME
to C:\Users\User_ID\AppData\Local\Temp\phantomjs\phantomjs-1.9.8-windows.zip.
restart the command prompt and run npm i or npm install