Error while loading shared libraries in dev containers and electron - node.js

Problem
I have an electron project inside a dev container and every time I do npm start inside the dev container I get this error:
>ProjectName#1.0.0 start /workspaces/ProjectName
>electron .
/workspaces/ProjectName/node_modules/electron/dist/electron: error while loading shared libraries: libxshfence.so.1: cannot open shared object file: No such file or directory
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! ProjectName#1.0.0 start:`electron .`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the ProjectName#1.0.0 start script
npm ERR! This is probably not a problem with npm. There is likely additional logginh output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/node/.npm/_logs/2021-04-30T21_59_57_871Z-debug.log
Access -> /home/node/.npm/_logs/2021-04-30T21_59_57_871Z-debug.log
How I got here
(I am on Debain 10 btw)
Created a remote container for Node 14 using the VS Code Command Palette
npm init -y
Added start script in package.json.
Installed electron npm install --save-dev electron#latest

This solution was made with the help of Alexander Leithner.
The problem is related to the lack of some libraries.
Solution:
Reopen the project locally.
And modify the Dockerfile in the .devcontainer folder.
Add the following line to the file:
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get -y install --no-install-recommends xorg openbox libnss3 libasound2 libatk-adaptor libgtk-3-0
Open the project in the dev container.

Related

updating node and npm from npm 6 to 8 and node 14 to 16 or 18 on a react native project , fails on ENOENT

Getting an error after running npm install,
It seems that npm is not pathed right for this file or something is cached?
I'm using homebrew and nvm to switch between versions, but the only version that works is node 14 and npm 6.
Need to install the following packages:
pod#0.9.0
Ok to proceed? (y) y
npm ERR! syscall chmod
npm ERR! path /Users/me/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/Users/me/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/me/.npm/_logs/2022-08-04T19_23_48_147Z-debug-0.log
npm ERR! code 254
npm ERR! path /Users/me/repos/MyApp/MyMobileApp
npm ERR! command failed
npm ERR! command sh /var/folders/d2/rdhvx2fd24vbsfrtf3lddq9m0000gq/T/postinstall-a0c95179.sh
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/me/.npm/_logs/2022-08-04T19_23_45_192Z-debug-0.log
```. i get User defaults from command line:
IDEPackageSupportUseBuiltinSCM = YES
error: Could not delete `/Users/me/repositories/MyApp/ios/build` because it was not created by the build system.
note: To mark this directory as deletable by the build system, run `xattr -w com.apple.xcode.CreatedByBuildSystem true /Users/me/repositories/MyApp/ios/build` when it is created.
error: Could not delete `/Users/me/repositories/MyApp/ios/build` because it was not created by the build system.
note: To mark this directory as deletable by the build system, run `xattr -w com.apple.xcode.CreatedByBuildSystem true /Users/me/repositories/MyApp/ios/build` when it is created.
** CLEAN FAILED **
Is now something that happens when I run xcodebuild -alltargets clean
This may be due to cache. Try below step and check if it works
Run rm -rf ~/.npm
Run npm cache clean --force
Remove node_modules (run rm -rf node_modules)
Remove package-lock.json (run rm -rf package-lock.json)
It happens when npm install conflict with peer dependencies
--legacy-peer-deps that ignores all peer dependencies when installing.
So the best approch is to use --legacy-peer-deps
npm install --legacy-peer-deps

Installing dependencies with npm-peer-dependencies

I am trying to install the required node_modules for a small project running Angular 11 using npm install
My goal is get the project to work locally after downloading it from GitHub. I have already installed the latest version of the Angular CLI.
After running the install command I tried npm start.
I was expecting that after running the install and start command to be able to run the project locally.
However the actual result I get after running the install command is the following list of errors:
> ng serve
An unhandled exception occurred: Cannot find module '#angular/compiler'
Require stack:
\node_modules\#angular\compiler-cli\index.js
\node_modules\#ngtools\webpack\src\angular_compiler_plugin.js
\node_modules\#ngtools\webpack\src\index.js
\node_modules\#angular-devkit\build-angular\src\webpack\configs\typescript.js
\node_modules\#angular-devkit\build-angular\src\webpack\configs\index.js
\node_modules\#angular-devkit\build-angular\src\browser\index.js
\node_modules\#angular-devkit\build-angular\src\dev-server\index.js
\node_modules\#angular-devkit\architect\node\node-modules-architect-host.js
\node_modules\#angular-devkit\architect\node\index.js
\node_modules\#angular\cli\models\architect-command.js
\node_modules\#angular\cli\commands\serve-impl.js
\node_modules\#angular-devkit\schematics\tools\export-ref.js
\node_modules\#angular-devkit\schematics\tools\index.js
\node_modules\#angular\cli\utilities\json-schema.js
\node_modules\#angular\cli\models\command-runner.js
\node_modules\#angular\cli\lib\cli\index.js
\node_modules\#angular\cli\lib\init.js
\node_modules\#angular\cli\bin\ng
See "angular-errors.log" for further details.
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file C:\WINDOWS\system32\cmd.exe
npm ERR! errno ENOENT
npm ERR! `ng serve`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the #0.0.16 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
The problem is that this Angular project also has peer dependencies. I installed npm-install-peers package but it seems that simply running npm install afterwards will not install the required peer dependencies.
What should I do next to get this Angular project installed locally ?
The issue you are facing is likely because angular cli or npm-peer-dependencies are not installed globally on your machine.
The steps that you should take are to make sure of them are globally installed.
To install packages globally you need run npm install -g <package_name>
npm docs link
In your case for angular cli you should run
npm i -g #angular/cli#11.2.15 and npm install -g npm-peer-dependencies.
Then run npm start.

How to update npm in WSL 2 Ubuntu

I'm trying to update my ancient npm 3.5.2 that is running in the Windows Subsystem for Linux on my Windows 10 to the latest version.
The command I'm running is as follows:
sudo npm install -g npm#latest
However, it fails and all I'm getting is the following output:
WARN engine npm#7.20.5: wanted: {"node":">=10"} (current: {"node":"8.10.0","npm":"3.5.2"})
/usr/local/lib
└── (empty)
sudo apt install wsl
npm ERR! Linux 5.10.16.3-microsoft-standard-WSL2
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "npm#latest"atest
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! path /usr/local/lib/node_modules/.staging/#npmcli/ci-detect-c7bf9552
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/#npmcli/ci-detect-c7bf9552' -> '/usr/local/lib/node_modules/npm/node_modules/#npmcli/ci-detect'
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/#npmcli/ci-detect-c7bf9552' -> '/usr/local/lib/node_modules/npm/node_modules/#npmcli/ci-detect'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /mnt/d/Summbit/Humanatomy.Web/npm-debug.log
npm ERR! code 1
I'm clueless what npm is trying to tell me. Does anyone know what is going on here?
I found this article that detailed the steps that eventually enabled me to update npm. These are the steps that I followed:
Step:
sudo npm cache clean -f
output:
npm WARN using --force I sure hope you know what you are doing.
Step:
sudo npm install -g n
output:
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
/usr/local/lib
└── n#7.3.1
Step:
sudo n stable
output:
installing : node-v14.17.4
mkdir : /usr/local/n/versions/node/14.17.4
fetch : https://nodejs.org/dist/v14.17.4/node-v14.17.4-linux-x64.tar.xz
installed : v14.17.4 (with npm 6.14.14)
Note: the node command changed location and the old location may be remembered in your current shell.
old : /usr/bin/node
new : /usr/local/bin/node
To reset the command location hash either start a new shell, or execute PATH="$PATH"
Step:
sudo n latest
output:
installing : node-v16.6.1
mkdir : /usr/local/n/versions/node/16.6.1
fetch : https://nodejs.org/dist/v16.6.1/node-v16.6.1-linux-x64.tar.xz
installed : v16.6.1 (with npm 7.20.3)
Step:
Close the shell and open a new one
Step:
npm --version
output:
7.20.3
There's a workaround:
npm install -g yarn
yarn global add npm
~/.yarn/bin/npm install -g npm
Some thing to note:
my nodejs was installed using nvm under ~/.nvm
you need to close vscode if you have it running in wsl mode, and restart bash. some file might be hold by vscode-server process.

NPM on new Mac with transferred files from my previous linux system. Problem with npm start on VS CODE terminal

Hey people...transferred some working js files from old linux to my new macbook air. Upon trying to start my files with NPM start in the vs code terminal, I'm getting this error: (please help!)
Galias-MacBook-Air:react-nextagram Guy$ npm start
react-nextagram#0.1.0 start /Users/Guy/Desktop/Next Academy/react-nextagram
react-scripts start
sh: /Users/Guy/Desktop/Next Academy/react-nextagram/node_modules/.bin/react-scripts: cannot execute binary file
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! react-nextagram#0.1.0 start: `react-scripts start`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the react-nextagram#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Guy/.npm/_logs/2019-01-24T01_15_13_056Z-debug.log
Galias-MacBook-Air:react-nextagram Guy$
Me too. I migrate from Ubuntu 18.04 to OSX Catalina. This is how I solve :
Delete your node_modules and npm install or npm install -s
Problem is inside your node_modules
The problem here is that you have compiled dependencies. One or more of the packages you use on your application need to be compiled against the OS you are going to run them in. To fix this, you can try one of the options bellow:
This will rebuild everything against your current OS.
npm rebuild
Or
you can do a clean install.
rm -rf node_modules && npm install

npm i Running command - failed! (exit code 254)

Ionic :3.20.0
node: v8.10.0
npm: 5.6.0
npm i
✖ Running command - failed!
[ERROR] An error occurred while running npm i (exit code 254):
npm ERR! path
/Users/lucaszimmermann/Desktop/myApp/node_modules/tsickle/src/main.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod
'/Users/lucaszimmermann/Desktop/myApp/node_modules/tsickle/src/main.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR!
/Users/lucaszimmermann/.npm/_logs/2018-04-04T16_41_39_270Z-debug.log
I faced a similar issue after doing the below actions this issue solved.
Delete package-lock.json file.
Open cmd/terminal in administrator mode.
run command: npm install
run command: npm update
Node version is likely incompatible. There'd be an expected version actual version. Use nvm or similar to install and change node versions.
Delete node_modules and try install again. You probably get a message similar to:
error ts-jest#26.1.2: The engine "node" is incompatible with this module. Expected version ">= 10.21.0". Got "10.20.1"
error Found incompatible module.
You wan't try to install npm packages.
You have two options to install some packages:
First Option:
npm install <package>
npm i <package>
Second Option:
If you wan't to create an automated installation process without each package, you must provide an packge.json - Here are all depencies listed. You can only run npm i or npm install without an package name, if you have an package.json
A full documentation about that is on NPM: https://docs.npmjs.com/files/package.json

Resources