Truffle failing to install on a Mac M1 - truffle

I am trying to install Truffle on my mac M1.
I started by following the instructions on the truffle web site in the Pet Shop tutorial I got node installed node successfully, but then I get this error...
sudo npm install -g truffle
...
npm ERR! xcrun: error: unable to load libxcrun (dlopen(/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib, 0x0005): tried: '/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libxcrun.dylib' (no such file)).
I did a bit of research and was pointed at trying it in homebrew instead. I had to update homebrew first because of my M1 chip, which I did successfully. But I still get what appears to be the same or similar error...
/opt/homebrew/bin/brew install truffle
...
xcrun: error: unable to load libxcrun (dlopen(/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib, 0x0005): tried: '/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libxcrun.dylib' (no such file)).
truffle: The x86_64 architecture is required for this software.
I can't find out much about this online.
Does this mean that truffle only runs on intel chips and I need to use something like rosetta?

OK, so I finally figured this out and thought I would post here for posterity.
The issue was the version of the xcode command line tools that I had installed on my M1 Mac. I have no idea how, but it was an out of date version. The fix was to remove the command line tools and reinstall them. I think (I cannot say for certain) that this replaced them with M1/Arm versions and then the compile tools needed were in place.
To update I followed the steps in this Apple Developer Forum post
https://developer.apple.com/forums/thread/694283
Basically...
junk the existing folder
sudo rm -rf /Library/Developer/CommandLineTools
re-install
sudo Xcode-select --install
After doing this I re-ran
sudo npm install -g truffle
and it completed successfully (albeit with a bunch of audit warnings)

Related

Installation of Angular failed in Ubuntu 18.04.4 LTS

I am aware that this problem has already been reported before in this forum, but none of the proposed solutions (at least the ones I understood) has worked for me, so I will explain my case in detail.
I could successfully install both NodeJs and Angular CLI, but once there it doesn't recognize the ng command.
It says the command ng was not found, but it can be installed with sudo apt install ng-common.
But when I do so, then each time I use ng it appairs something unexplainable for me:
From there I can only abort the process with ctrl-z.
An odd thing is that the first time I installed it, it allowed me to use ng new and create a project. But then this problem started when I tried ng serve. And from there I have never been able to use the ng command, even though I have uninstalled and installed programs as suggested by various forums. For example, I have already tried:
sudo apt remove ng-common
sudo npm uninstall -g #angular/cli
sudo npm install -g #angular/cli
When I do that, the editor does not appear as in the image any more, but it returns to the state when ng is not recognized.
I have also tried:
sudo apt purge ng-common ng-latin
sudo npm install -g #angular/cli
and it didn't work either.
Those are the versions I have installed:
npm --version: 3.5.2
node --version: v8.10.0
+ #angular/cli#9.1.7
Visual Studio Code: 1.45.1
Chromium 83.0.4103.61 snap
Ubuntu 18.04.4 LTS
Maybe your path doesn't include the location of the global node_modules folder.
Try to find the install location of #angular/cli (possibly in /usr/local/lib/node_modules).
To add this folder to the PATH environment variable, add to your ~/.bashrc:
export PATH="/usr/local/lib/node_modules:$PATH"
After a shell restart you should be able to issue the ng command.
To know which ng are you using, issue the command:
which ng
This seems an issue that can have several causes. In my case I could solve it by using alias:
alias ng="/home/mario/node_modules/#angular/cli/bin/ng"

Error while executing the “npm install” command in ubuntu 18.04 LTS

I have been trying to install and run my first hyperledger fabric application (http://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html) but have been encountering the following issue everytime I run the "npm install" command.
Please let me know what is the solution to resolve this issue.
The error is as follows:
I have tried deleted .node-gyp, .npmrc folder from $HOME and restarting the computer.Nothing helped.
Faced a similar issue in Centos 7 and resolved by installing the development tools..
To compile and install native addons from npm you need to install the development tools.
Running the following commands will resolve your issue;
sudo apt install gcc g++ make
npm install
node-gyp has dependency on ms visual basic redistributable. You have to check that relation and install. Hope you have done that.
Change the python version to 2.7. Then run
npm install -g --production windows-build-tools
as administrator.

Why is node-gyp rebuild failing on Mac OSX El Capitan

I recently bought a mac, which uses Mac OSX El Capitan v10.11.4. Installed node with homebrew, and am using node v6.2.2 and npm v3.9.5. I'm getting an error with bcrypt during npm install, which I believe derives from a node-gyp rebuild error. I also recently downloaded xcode-select(version 2343) and xcode(7.3.1) (in that order).
Here is the full error output after i run npm install:
https://gist.github.com/varunjayaraman/5734af617d616437cd5b3456b20bc503
Not sure what's going wrong. I come from linux land and do tend to be wary of not installing from source myself, so maybe that is the cause of these issues? Anyway, any advice would be super appreciated. I also saw this error springing up for others, but none of their solutions seemed to work (when i type xcode-select --print-path, I get /Applications/Xcode.app/Contents/Developer)
Anytime i upgrade OSX to newer version, I get the same issue.
Here is how i solve it every time:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
That's it. Now next time you do npm install or yarn it'll work.
PS: Sometimes you won't be able to install the command line tool through Xcode-select, for example if you are on beta.
In that case, you should be able to install it manually from here: https://developer.apple.com/download/more/
This one just bit me, too. There were a couple of different solutions, only one of which worked for me.
First, make sure you have the XCode command line tools installed, as they say on their npm page.
1) The simplest solution, which of course didn't work (though it looks like it did for some people), is to just delete the ~/.node-gyp directory. So might as well give that a shot, as well as deleting your node_modules dir and doing another npm install.
2) Try uninstalling node-gyp and re-installing:
sudo npm uninstall node-gyp -g
npm uninstall node-gyp
npm install
3) But what did the trick was a solution given in a node-gyp issue on github, where you have to install another version of node and do your npm install that way. It's easier than it sounds, but it's pretty gross:
sudo npm cache clean -f
sudo npm install -g n
sudo n 4.4.5
sudo npm install npm -g
sudo npm uninstall node-gyp -g
Then try running npm install.
Hope that helps!
If the node_modules cache was built with a recent version of Node, you may need to remove the cache, revert back and then reinstall the packages:
rm -rf node_modules
nvm use 6
npm install
I have a simple solution. If the xcode-sellect is installed try running
sudo xcode-select --reset
Same issue I had after upgrading macOS
Update brew
brew update
Update X-Code
xcode-select --install
If needed, you may have to reset the path to X-Code
xcode-select --switch /Applications/Xcode.app
xcode-select --switch /Library/Developer/CommandLineTools
For anyone who tried reinstalling Xcode tools yet the same issue persists.
You will have to go following file:
~/.node-gyp/<your_node_version_here>/include/node/common.gypi
Note: Make sure to change <you_node_version_here> to your node version like:
~/.node-gyp/16.13.1/include/node/common.gypi
You can find node version using
node -v
Inside search for key MACOSX_DEPLOYMENT_TARGET and change it's value to your current os version like mine is 11.3.1 and you will be good to go.
You can find version in
about this mac
option in drop down of mac logo
If you are using virtualenv for your python, you need to deactivate it or point npm to use the OS's own python 2 installation for node-gyp to work.
EDIT:
Had another encounter with the same bug a few days ago. This time around node-gyp was not at fault. Apparently the module I was installing has a dependency on a very old version of node-gyp (v1), independent of the system's version (v3.8), which my version of node (v10) no longer supports. Since I did not need that module anymore, I removed it. Alternatively, you may wish to upgrade/downgrade/replace the offending module, or upgrade/downgrade your node. For the OP's case, the offending module was bcrypt#0.8.5.
if you want to upgrade Node to 10 or above, you have to find dependencies out of date with Node 10 in package.json and upgrade these packages to newer stable version, then build (npm/yarn install).
Try looking at your python install.
I found a hint at the discussion here https://github.com/nodejs/node-gyp/issues/489#issuecomment-431447692.
My python on my MacBook Pro is managed by Homebrew which installs binaries to
/usr/local/bin
So I did the following in terminal:
>$: npm config set python /usr/local/bin/python
>$: rm -rf node_modules
>$: npm i
I had a similar issue.
A lot of folks have recommended that you install Xcode, and point xcode-select to the /Applications/Xcode.app/Contents/Developer. However, there is one more step.
That is to confirm that the /Applications/Xcode.app/Contents/Developer folder has SDK version corresponding to the MacOS version your actual computer is running on.
If it does not, go into /Library/Developer/CommandLineTools and copy that over.
I had a similar issue and running the commands below fixed it for me
Install xcode
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
You need to re-install XCode Tool in order to compile your codes in your machine:
* xcode-select -print-path
* sudo xcode-select --reset
* xcode-select -print-path
Here's the main link you can install it on MacOS:
https://github.com/nodejs/node-gyp/blob/main/macOS_Catalina.md

NPM error on Mac OS X 10.5

I've to work for a project on Mac. But i've some problems for install nodejs.
When i make node -v on the terminal it's ok but when i wan't to use the command npm that doesn't work, i've this error:
npm -v
dyld: lazy symbol binding failed: Symbol not found: __ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
Referenced from: /usr/local/bin/node
Expected in: /usr/lib/libstdc++.6.dylib
dyld: Symbol not found:
__ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l Referenced from: /usr/local/bin/node Expected in:
/usr/lib/libstdc++.6.dylib
Trace/BPT trap
So if anyone can help because i really don't know how to fix the problem...
Thank's
#Kreepz - I recently had some machine problems, had to use an old machine, and ran into the same issues. Fear not, there is a solution!
Before we get started, please make sure you have Xcode installed on the machine. The version needed is 3.1.4 - which can be downloaded for free by registering with Apple and searching for it in Apple's dev tools here
Secondly, to save us ALOT of headaches, we're going to use brew to install node. That said, OS X 10.5.x does not support homebrew, but it does support tigerbrew.
To install tigerbrew, enter the following from your command line:
ruby -e "$(curl -fsSkL raw.github.com/mistydemeo/tigerbrew/go/install)"
Next, run the following to make sure brew is up to speed:
brew doctor
After running brew doctor you'll need to pay attention to the output closely. It's going to let you know about issues that must be resolved in your system. Address them and run brew doctor again until things look good.
Then, we'll need to make sure we can compile everything without hiccups. Before installing node, run the following:
brew install gcc48
Woop woop! Now what's next? You guessed it - let's install node:
brew install node
Now, that last command is going to take a while. If it fails, run brew doctor again and make sure all the warnings and errors are resolved. If you're still having issues, check the tigerbrew troubleshooting page here.
I hope that this helps you or anyone else looking at this! Good luck!

Cordova: You may not have the required environment or OS to run this project

On Linux Mint 17.1 x86_64, Cordova v4.3.0 gives this error:
$ cordova run android
Running command: /home/naman/test/platforms/android/cordova/run
WARNING : No target specified, deploying to emulator
WARNING : no emulator specified, defaulting to Sample
Waiting for emulator...
Booting up emulator (this may take a while)....BOOT COMPLETE
/home/naman/test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error: ENOENT, no such file or directory '/opt/software/android-sdk/tools/tools/lib/build.template'
at Object.fs.openSync (fs.js:432:18)
at Object.fs.readFileSync (fs.js:286:15)
at /home/naman/test/platforms/android/cordova/lib/build.js:129:40
at _fulfilled (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:760:13)
at /home/naman/test/platforms/android/cordova/node_modules/q/q.js:574:44
at flush (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
ERROR running one or more of the platforms: Error: /home/naman/test/platforms/android/cordova/run: Command failed with exit code 8
You may not have the required environment or OS to run this project
PATH variable seems to be alright (the path for SDK is correct):
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/software/android-sdk/tools:/opt/software/android-sdk/platform-tools
I installed it using :
sudo apt-add-repository ppa:cordova-ubuntu/ppa
sudo apt-get update
sudo apt-get install cordova-cli
npm install -g cordova
The installation went smoothly and the project was created without any error.
Am I missing some dependency?
You may need to uninstall the existing app on your device.
I installed my app on that device from another computer. When I run cordova run android I get
You may not have the required environment or OS to run this project.
But when I try to install my apk by adb it told my that the app was already installed. So I uninstalled it an it worked.
For others having this problem, assuming you have already checked and fixed any environment variables using #Naman Dixit's answer, you may also have to remove and add your platforms:
cmd: cordova platform rm [platform(s) of interest]
delete everything in the [yourproject]/platforms folder. Then:
cmd: cordova platform add [platform(s) of interest]
that was the final step I needed to get everything to work
Make sure you have proper environment variables defined (add this in .bash_login or .profile and do source .profile):
export ANDROID_SDK="/opt/software/android-sdk"
export ANDROID_NDK="/opt/software/android-ndk"
export ANDROID_HOME="$ANDROID_SDK"
export ANDROID_PLATFORM_TOOLS="$ANDROID_SDK/platform-tools"
export PATH="${PATH}:$ANDROID_HOME/tools:$ANDROID_PLATFORM_TOOLS"
Your android sdk doesn't seem to be properly installed or you didn't install the proper android sdk version that has the dependency that you seem to be missing
/opt/software/android-sdk/tools/tools/lib/build.template
I encountered this issue now too. The problem in my case is that the ant.properties file that I'm using is pointed to wrong and NOT existing file.
key.store=D:/Fedmich/_keys/android.keystore
After correcting it, I was able to compile a release apk.
Hope this helps someone in the future. Just be sure to read the error_logs that is given in the command prompt.
This is just to have one more reason for this error documented here and for them who are still searching for solution.
When I came accross this error, I tried almost all the solutions listed on the stackoverflow.
My issue was my device was not getting detected by adb, adb kill-server/start-server also not helped me, ***
but changing USB port helped.
I got a same error
my solution is underlying.
command adb device
no result.....
install usb drive for mobile (my phone is lg g3)
reeboot and command adb device again : result device showing.
then tried again
3. ionic run adnroid --device
"OK";
Happens when platform is added without internet connection.
Ensure internet is OK and type :
cordova platform remove blackberry10
cordova platform add blackberry10
Try to build and run :
cordova run
Hope this fix your problem, also for other platform
I got this error after installing the Crosswalk plugin. To solve it I installed the latest Android SDK, deleted the android folder under platforms and ran
phonegap build android
alternatively
cordova platform add --save android
cordova build android
and it was all good.
I had the same error building the android platform, and no solution given here could help me.
I decided to run the gradlew command shown by cordova, and saw there was a problem with a png file included in the cordova project.
After removing it, I managed building the platform again.
export ANDROID_HOME=/Applications/adt-bundle-mac-x86_64-20140321/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
then cordova run android works
Ubuntu
If you are having issues on Ubuntu, you may want to try installing the following packages, per the docs:
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386
You may also need to install this package:
sudo apt-get install lib32z1

Resources