'darwin-arm64v8' binaries cannot be used on the 'darwin-x64' platform - node.js

I am trying to deploy functions to firebase using my Mac M1, for which it was required to do an npm install to install packages in node_modules/.
I am getting this error:
Error: 'darwin-arm64v8' binaries cannot be used on the 'darwin-x64' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'darwin-x64' platform.
at Object.hasVendoredLibvips (/Users/ali/Desktop/tajir/backend-mvp/appengine/back-end-flex/node_modules/sharp/lib/libvips.js:80:13)
at Object.<anonymous> (/Users/ali/Desktop/tajir/backend-mvp/appengine/back-end-flex/node_modules/sharp/lib/constructor.js:7:22)
at Module._compile (internal/modules/cjs/loader.js:1136:30)
at Module._compile (pkg/prelude/bootstrap.js:1394:32)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1156:10)
at Module.load (internal/modules/cjs/loader.js:984:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1024:19)
at Module.require (pkg/prelude/bootstrap.js:1338:31)
at require (internal/modules/cjs/helpers.js:72:18)

Usually someone having a Mac M1 would have this issue. The Mac M1 processor is arm64. There was a solution posted here which requires to change terminal architecture to arch -x86_64 zsh which I did not want to do.
So, that's the workaround I was able to discover (some of the steps also mentioned in the error):
rm -rf node_modules/sharp
npm install --arch=x64 --platform=darwin sharp

For me, all I had to do was:
brew reinstall vips
then do a clean install of the project.

My answer is not related to deploying functions to firebase, but I had that exact same error:
Error: 'darwin-x64' binaries cannot be used on the 'darwin-arm64v8' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'darwin-arm64v8' platform.
when I tried to run a project with a mac M1 using a version of node that was incompatible.
I tried to run the project with version 16 when the project actually require version <=14.
So if anyone has this problem might be worth checking the node version

For some reason I got it fixed with removing node_modules and installing them again.
Error: 'darwin-x64' binaries cannot be used on the 'darwin-arm64v8' platform.
Please remove the 'node_modules/sharp' directory and run 'npm install' on the
'darwin-arm64v8' platform.

I got this error today spinning up a Gatsby app locally. Reverting to the Node version that I used when installing the originally Gatsby application worked for me to get past it. Switched from Node v16 to v14.20.

Related

Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (72)

I'm using macOS Catalina 10.15.3.
I'm generating thumbnail images with this Jekyll theme, and when I enter gulp img, that error occurs.
Requiring external module babel-register
~/node_modules/node-sass/lib/binding.js:13
throw new Error(errors.unsupportedEnvironment());
^
Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (72)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.7.1
at module.exports (~/node_modules/node-sass/lib/binding.js:13:13)
at Object.<anonymous> (~/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:1157:30)
at Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
at Object.require.extensions.<computed> [as .js] (~/node_modules/babel-register/lib/node.js:152:7)
at Module.load (internal/modules/cjs/loader.js:1001:32)
at Function.Module._load (internal/modules/cjs/loader.js:900:14)
at Module.require (internal/modules/cjs/loader.js:1043:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (~/node_modules/gulp-sass/index.js:187:21)
I tried everything, like npm install, npm uninstall, npm rebuild node-sass, and so on, but I don't know why the error appears.
I had the same problem. For me it helped to reinstall NodeJs (in my case 14.15.1 LTS) and then the already mentioned command:
npm rebuild node-sass
I had the same problem. Tried to rebuild node-sass after the most recent Mac OS update using other answers. Switching to Dart Sass was my last resort after update node, npm, reinstalling all packages and rebuilding node-sass.
node-sass is deprecated in favor of dart sass:
https://www.npmjs.com/package/node-sass
https://sass-lang.com/dart-sass
After uninstalling node-sass and installing sass, I still get warnings when doing yarn build, but my react project is building again.
npm uninstall node-sass
npm install sass
In addition to Charles Letcher's response above, I wanted to add that the npm sass version also works for those on ARM/M1 architecture.
I took my existing Gulp project and installed sass on Node v14 and Node v16. Once this happened, my project launched flawlessly.

Deploy Meteor app to Synology armv7: There is an issue with `node-fibers`

I've spent a couple of days trying to run a build app from Meteor on my Synology ds213j (Armv7, 512MB ram).
I keep encountering the following error
## There is an issue with `node-fibers` ##
`/volume1/homes/user/app/bundle/programs/server/node_modules/fibers/bin/linux-arm-57/fibers.node` is missing.
Try running this to fix the issue: /volume1/homes/user/.nvm/versions/node/v8.11.2/bin/node /volume1/homes/user/app/bundle/programs/server/node_modules/fibers/build
Error: /volume1/homes/user/app/bundle/programs/server/node_modules/fibers/bin/linux-arm-57/fibers.node: internal error
at Object.Module._extensions..node (module.js:681:18)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/volume1/homes/user/app/bundle/programs/server/node_modules/fibers/fibers.js:13:39)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
/volume1/homes/user/app/bundle/programs/server/node_modules/fibers/fibers.js:22
throw new Error('Missing binary. See message above.');
^
Error: Missing binary. See message above.
at Object.<anonymous> (/volume1/homes/user/app/bundle/programs/server/node_modules/fibers/fibers.js:22:9)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/volume1/homes/user/app/bundle/programs/server/boot.js:1:75)
at Module._compile (module.js:652:30)
BUT, fibers.node actually EXIST!
What I did before:
build meteor app meteor build --server-only --architecture os.linux.x86_32
on the /program/server folder npm install --production
npm install fibers
What I tried to fix it:
go to /programs/server/ and run npm install fibers (and reinstall)
installing from source following the instructions on
https://www.npmjs.com/package/fibers
my meteor app uses Node 8.11.2 but the only node version available for synology is 8.9.4. Removed it and manually installed the 8.11.2
build an default meteor app to check if is my app giving problems.
Nothing worked so far and I have no idea what to do next.
I suspect the problem is that fibers is built for linux-arm-57 and I suppose I need arm-7I?
There is something I can do to make this work?
Thanks!
In the following I describe the way you correctly deploy your app to an ARMv7 device. By doing so I will highlight important steps that may often be cause of errors. I hope your problem will solve by reproducing these steps.
1. Build your production app
Make sure the app starts, runs and all your tests pass on local.
Get your current development version of node. Note, that it varies, depending on the meteor version your project uses. Note: The meteor guide on custom deployment underlines the importance of a matching node version.
$ cd ~/path/to/meteor-project
$ meteor node -v
v8.9.4 # this example uses Meteor 1.6.1 which uses node 8.9.4
build your production app using the build command (I adapted your specs a bit here).
$ cd ~/path/to/meteor-project
$ meteor npm install --production
$ meteor build ../build/deployment-test --server-only --architecture os.linux.x86_32
2. Prepare your target device' environment
Meteor builds are also Node.js applications. Your device will require an ARMv7 build of Node.js. The easiest way to do that is to use the install script from nodesource (open in new tab to view the script).
$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt-get install -y nodejs
Note, that official node installation guide also points out, that "To compile and install native addons from npm you may also need to install build tools". You will need this, because fibers or bcrypt are such native addons.
$ sudo apt-get install -y build-essential
Verify your installed node version
$ node -v
v8.11.4 # but we need v8.9.4
The easiest way to get the correct version of node, that exactly matches your development version, is to use the npm n package.
$ sudo npm install -g n
$ sudo n 8.9.4
$ # ... installs target version
$ node -v
v8.9.4 # if this is still the old version just restart the shell
if you need help on this, read this github issue thread
finally install mongodb >= 2.6 (important!) on your target device (not covered in this answer).
3. Install your production app on the target device
copy / move / upload your build archive to your target device
extract your deployment bundle
$ cd ~/path/to/deploymentapp
$ tar -xvzf ./meteor-project.tar.gz # extracts all content into a folder named 'bundle'
install npm dependencies on target system
$ cd bundle/programs/server/
$ npm install --production
if you have replicated all the above steps the npm packages (and espeically the native packages, such as fibers or bcrypt) should be installed here without any errors. Now go back to bundle/ and start the app:
$ cd ../../
$ MONGO_URL=mongodb://yourmongodbcredentials node main.js
I hope by replicating this guide you will find a solution to your problem.
Added for SEO reasons: This guide shows how to deploy a Meteor app on a Raspberry PI with ARMv7 architecture and Raspbian (32 bit) installed. It can also be used as a foundation for other ARMv7 devices, such as OP's Synology.

Error: Failed to load gRPC binary module

I have been following the tutorial: https://docs.particle.io/tutorials/integrations/google-cloud-platform/
trying to send humidity and temperature data from a Particle Photon to Google Cloud Datastore. The high level architecture is as follows:
where data is sent from the Photon to Particle Cloud to Google Cloud (Pub/Sub) and to Google Datastore with Node.js as an intermediary.
Everything works to Pub/Sub but as I try to activate the node script (calling: node tutorial.js) I receive errors.
When calling node tutorial.js I receive:
$ node tutorial.js
Authenticating with Google Cloud...
/home/lennart/node_modules/grpc/src/grpc_extension.js:55
throw error;
^
Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: node-v64-linux-x64-glibc
Found: [node-v57-linux-x64-glibc]
This problem can often be fixed by running "npm rebuild" on the current system
Original error: Cannot find module '/home/lennart/node_modules/grpc/src/node/extension_binary/node-v64-linux-x64-glibc/grpc_node.node'
at Object.<anonymous> (/home/lennart/node_modules/grpc/src/grpc_extension.js:53:17)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/lennart/node_modules/grpc/src/client_interceptors.js:145:12)
at Module._compile (internal/modules/cjs/loader.js:702:30)
I tried npm rebuild as suggested in the error message, but this made no change.
Current versions of different packages:
$ npm -v
6.1.0
$ node -v
v10.4.1
$ openssl version -v
OpenSSL 1.0.2o 27 Mar 2018
Previously I had problems with OpenSSL and Node compatability, which could be traced from: Error undefined symbol: SSL_library_init. Node v10.4.1 was installed which then seemed to cause the above error.
I finally solved this by doing the following:
Making sure the right version of Node was installed:
npm install --target=10.0.0 --target_platform=linux --target_arch=x64
Copying the folder node-v64-linux-x64-glibc to two other folders (see below) apart from where it initially had been installed (/home/lennart/Desktop/Cloud/google-cloud-datastore-tutorial-master/node_modules/grpc/src/node/extension_binary) via the previous command.
/home/lennart/node_modules/#google-cloud/video-intelligence/node_modules/grpc/src/node/extension_binary
/home/lennart/node_modules/grpc/src/node/extension_binary
This could probably be solved in a more elegant way, but at least it worked.
I am experiencing the same issue with node:10-alpine base image in Docker.
The solution that works for me is running additionally npm rebuild on the container's entry point.
FROM node:10-alpine
WORKDIR /app
COPY package*.json .
RUN npm install
COPY . .
CMD npm rebuild && npm run migrate:run
Probably running the same npm rebuild should resolve the issue locally, or, perhaps this is a problem with npm as it cannot fetch the proper binary timely.
Would yarn make a difference?
Please check the NODE&NPM version of reguler user and SUPER USER NODE&NPM versions are same.
For me a simple yarn --force did it, once I used nvm to switch to the proper node.js version. I had originally done yarn with the wrong version.

The edge module has not been pre-compiled for node.js version v6.3.0

When I try to build my app from vs2015 update3 for ios, I get this error during compile
The edge module has not been pre-compiled for node.js version v6.3.0. You must build a custom version of edge.node. Please refer to https://github.com/tjanczuk/edge for building instructions
I went to that project on github, but I couldn't find anything usefull.
also I run sudo npm i edge on mac and edge compiles fine but still can't build the app
also I cleared the npm cache on mac by sudo npm clear cache still build error
My environment on mac is:
node 6.3.0
npm 3.10.6
cordova 5.4.1
My environment on windows
Win10
Vs2015 update 3
node 6.3.0
npm 3.10.6
cordova 5.4.1
Update 1
when I try to install edge by npm install edge on windows I get the same error in npm
edge#5.9.2 install C:\Users\Reza\node_modules\edge
node tools/install.js
***************************************
Error: The edge module has not been pre-compiled for node.js version v6.3.0. You must build a custom version of edge.node. Please refer to https://github.com/tjanczuk/edge for building instructions.
at determineVersion (C:\Users\Reza\node_modules\edge\lib\edge.js:21:11)
at Object.<anonymous> (C:\Users\Reza\node_modules\edge\lib\edge.js:33:102)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Reza\node_modules\edge\tools\checkplatform.js:2:2)
Success: platform check for edge.js: node.js x64 v6.3.0
C:\Users\Reza
`-- edge#5.9.2
In case somebody else has the same problem and saving couple of hours for him/her:
Finally
downgrade the node.js to v0.12.7 (x86) on windows machine, and no change on mac machine,
clear cordova cahce in visual studio->tools->options->tools for apache cordova
and then it start building fine for ios

Nodejs Cannot find module '../build/Release/canvas'

I installed cairo, and node-canvas. I tried everything, but still can't find module.
sudo apt-get install libcairo2-dev
sudo npm install canvas
sudo npm install canvas -g
If I run require('canvas'), I get this error:
Error: Cannot find module '../build/Release/canvas'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/home/tomas/node_modules/canvas/lib/bindings.js:2:18)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
I use Ubuntu linux
Thanks in advance.
In my case i have to spend lot of time to resolve this issue.
I just use "npm uninstall canvas" and then install using "npm i canvas"
Try this is if above option not works for you.
It seemed like the install script of canvas haven't been called in my case, too. Instead of deleting the lock file I just called the script manually which solved the issue in my case (at least temporarily).
Therefore, if the canvas package has been installed already, go to /node_modules/canvas/ and run npm run install which creates the build directory.
I had the same problem. The issue was that the install script for node-canvas never got executed, which is why the build folder was missing.
In my case, removing the yarn.lock file was the solution, as it skipped the node-canvas package installation for some reason. Once I let npm take care of the packages, it successfully installed node-canvas, ran the install script and the build folder showed up again.
Problem here looks like
1. Your node modules are installed in a different location But the node.js runtime is searching for it in a different place. Check the NODE_PATH and see if this is the case.
Refer the module loading explained in http://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
I had a similar problem but I used canvas-prebuilt which is a drop-in replacement for canvas and I fixed it for doing this:
npm install -g node-gyp and then node-gyp rebuild in the terminal
U can try it:
Delete NodeModule Folder
Use node version 14
Run dependency installations
sudo apt-get install libpixman-1-dev libcairo2-dev libpangocairo-1.0-0 libpango1.0-dev libgif-dev libjpeg-dev
If use ubuntu,try install above lib then install canvas.work fine for me。
If you use cnpm install the canvas. try npm.

Resources