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.
Related
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.
I'm trying to install node-sass on ubuntu, beacuse I want to use sass-autocompile, but even when I try to compile that sass file in atom (just when I save it)
It returns this error:
`fs.js:904
return binding.readdir(pathModule._makeLong(path), options.encoding)
Error: ENOENT: no such file or directory, scandir
'/usr/lib/node_modules/node-sass/vendor'
at Object.fs.readdirSync (fs.js:904:18)
at Object.getInstalledBinaries (/usr/lib/node_modules/node-
sass/lib/extensions.js:129:13)
at foundBinariesList (/usr/lib/node_modules/node-
sass/lib/errors.js:20:15)
at foundBinaries (/usr/lib/node_modules/node-sass/lib/errors.js:15:5)
at Object.module.exports.missingBinary (/usr/lib/node_modules/node-
sass/lib/errors.js:45:5)
at module.exports (/usr/lib/node_modules/node-sass/lib/binding.js:15:30)
at Object.<anonymous> (/usr/lib/node_modules/node-
sass/lib/index.js:14:35)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)`
I tried to use this command npm rebuild node-sass and it didn't fix the problem, even with --force
And removing nodejs and node-sass and npm and installing again didn't fix the problem and yes I do have ruby installed.
But one thing is really strange: this path node_modules/node-sass/vendor' exists in home folder, basically node_modules exists in home folder even with that vendor folder. Can you help me out ?
Here is the solution which works for me
sudo npm install --unsafe-perm node-sass
Update: Since node-sass is mostly deprecated use instead sass npm module(works perfect whithout any issues).You can find it HERE.
so after reading some of the workarounds on https://github.com/sass/node-sass/issues/1579 here is my suggestion
first remove node_modules directory and re-install dependencies npm install if its still not working then
node node_modules/node-sass/scripts/install.js
npm rebuild node-sass
if it's still not working, change your node-sass version to the latest and re-install it again
Thank you to anyone taking the time to help me. Let me start off by saying I'm very new to the coding world so I'm still trying to get my head around using terminal on a mac. So I have both jsnode and npm succesfully installed on my system. When I've installed browser-sync it seems to install fine. However, when I run browser-sync --version I get the following error.
Last login: Fri Jan 19 01:08:36 on ttys000
Marks-MacBook-Pro:~ Brent$ npm install -g browser-sync
/Users/Brent/.npm-global/bin/browser-sync -> /Users/Brent/.npm-global/lib/node_modules/browser-sync/dist/bin.js
+ browser-sync#2.23.5
updated 1 package in 6.436s
Marks-MacBook-Pro:~ Brent$ browser-sync --version
module.js:540
throw err;
^
Error: Cannot find module 'dev-ip'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/browser-sync/dist/utils.js:3:13)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
Marks-MacBook-Pro:~ Brent$
Also I don't know if this helps but I will show the PATH (not that I know what that means but I'm trying to read up):
Marks-MacBook-Pro:~ Brent$ echo $PATH
/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
Marks-MacBook-Pro:~ Brent$
Also, is there any harm in installing something that is already installed? As in, doesn't it just replace the files that already exist? The reason why I'm asking is that I have uninstalled/reinstalled jsnode and npm multiple times to the point where I feel like I might just need to try and uninstall everything again and try a new method. Just to reiterate, my main question is how to get browser-sync to install properly! Thank you.
I finally resolved this issue by using node version manager (nvm) instead of installing nodejs straight up. Here is a step by step guide to isntall nvm:
1.Completely uninstall nodejs. Use the terminal commands described here: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
The commands you need to use are highlighted in gray. Use either one of the top two commands (they are the same, as the OP describes) and then run the bottom command he lists as well.
Install Nodejs through NVM as described in STEP 0 of this blog: http://nodesource.com/blog/installing-node-js-tutorial-using-nvm-on-mac-os-x-and-ubuntu/ Basically he isntructs you to run a few command in the terminals. Note that you do not need to install the LTS versions (I don-t even know what they do), unless you want to.
Verify that NVM was installed properly. Skip to STEP 3 of the above blog.
4.Refresh the terminal (open and close it) and then use the command "nvm use node" It will spit out the node version you are using.
Install browser-sync using the "npm install -g browser-sync" command
Verify that browser-sync installed using "browser-sync --version" command
I just removed Node and reinstalled it with homebrew. I first installed without npm. Then removed that version and installed node with npm.
The install was successful but now I cannot use NPM.
Anything I try with NPM I get error
module.js:338
throw err;
^
Error: Cannot find module 'are-we-there-yet'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:2:16)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
I absolutely have no idea what to try. No npm command I can try. I tried removing and reinstalling node with homebrew but that doesnt work. Please help
UPDATE
I saw this answer: npm doesn't work, get always this error -> Error: Cannot find module 'are-we-there-yet'
But the solution did not work. I did not even have the folder
cd /usr/local/Cellar/node/0.10.22/lib/node_modules
In the lib folder there was no node_modules.
even npm i npm -g did not work.
Same issue when i install yarn , try:
install yarn
cd /usr/local/lib/node_modules/npm
sudo yarn add are-we-there-yet
it's working fine for me ,hope this helps for u.
I was having the same issue, try:
cd /usr/local/lib/node_modules
instead, then:
curl registry.npmjs.com/npm/-/npm-2.12.0.tgz |tar xz --transform="s:^package:npm:"
... and
npm i npm -g
I got node and NPM working again by removing the homebrew install of node, and then installing directly from node.js website using the installer. This might not be the best answer but it is working for me now.
Okay I struggled with this for 2+ hours on my toggle tracker and have a solution that worked for me. Note that I am not sure what goes wrong with the install process to result in this error, but various simple methods like sudo apt-get install nodejs, sudo apt-get install npm would then result in this error, I am guessing form incompatible/old package repositories. From a clean install this order of installation resulting in a working node / npm install that I could proceed with is as follows:
sudo apt-get update
sudo curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
This is basically updating and then following instructions from: https://github.com/nodesource/distributions
Hope this helps somebody else and doesn't take them 2 hours :')
I have encountered this issue a few times. For those of you that use the package n to manage your installation of node, you can just swap versions of node to fix this issue.
For example, first run
sudo n latest
and then run
sudo n stable
(or return to whatever version to wish to use).
If that doesn't fix it yet, then run
npm install -g npm
This is the easiest to recall approach for fixing the problem, assuming you use n (which I highly recommend to anyone that uses node)
To install n,
npm install -g n
Note, you probably will not be able to install n in order to fix this issue. This solution is only for those that already have n installed.
Got this error as well. What worked for me:
Delete /usr/local/lib/node_modules
Reinstall NodeJS: brew reinstall nodejs
Done!
Removing and reinstalling did not work. But I copied npm folder from C:\Program Files\nodejs\node_modules to
'C:\Users\xxx\AppData\Roaming\npm\node_modules' and worked. where xxx is user name
Here is the full error after typing yo polymer in a clean directory.
module.js:338
throw err;
^
Error: Cannot find module 'find-index'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/lib/node_modules/generator-polymer/node_modules/yeoman-generator/node_modules/download/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/index.js:4:17)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
I've just done a reinstall of everything node related, but here are the versions.
node: v0.12.7
npm: 2.11.3
yo: 1.4.7
bower: 1.4.1
grunt-cli: v0.1.13
gulp: 3.9.0
generator-polymer: 1.0.5
Note that I get a warning when installing generator-polymer.
npm WARN deprecated CSSselect#0.4.1: the module is now available as 'css-select'
npm WARN deprecated CSSwhat#0.4.7: the module is now available as 'css-what'
I have also tried installing the three problematic modules manually, which appeared to be successful.
sudo npm install -g find-index css-select css-what
I'm out of ideas. Node was installed from source downloaded at nodejs.org.
EDIT:
I have also installed n using sudo npm install -g n to install node. I have tried uninstalling/reinstalling node/npm with no luck.
EDIT2:
yo webapp works, so the culprit is (must be?) generator-polymer.
I see you are installing it to global modules. Did you try to install generator-polymer just for project (it should fix warnings)
You list only root packages version. But problem seems to be in dependencies. Accordign your stack trace it's caused by yeoman-generator / download module
Here is my versions of all depes. Look at this packages and check your version (i have yeoman-generator#0.18.10 and download#3.3.0 which works fine)
generator-polymer#1.1.0 node_modules/generator-polymer
├── ncp#2.0.0
├── chalk#1.1.0 (escape-string-regexp#1.0.3, supports-color#2.0.0, ansi-styles#2.1.0, has-ansi#2.0.0, strip-ansi#3.0.0)
├── lodash#3.10.1
├── validate-element-name#1.0.0 (log-symbols#1.0.2, ncname#1.0.0)
├── rimraf#2.4.2 (glob#5.0.14)
├── yosay#1.0.5 (ansi-regex#1.1.1, ansi-styles#2.1.0, strip-ansi#2.0.1, word-wrap#1.1.0, pad-component#0.0.1, minimist#1.1.3, taketalk#1.0.0, repeating#1.1.3, string-width#1.0.1)
└── yeoman-generator#0.18.10 (read-chunk#1.0.1, dargs#3.0.1, detect-conflict#1.0.0, yeoman-welcome#1.0.1, xdg-basedir#1.0.1, user-home#1.1.1, class-extend#0.1.1, diff#1.4.0, text-table#0.2.0, mime#1.3.4, underscore.string#2.4.0, async#0.9.2, run-async#0.1.0, istextorbinary#1.0.2, debug#2.2.0, nopt#3.0.3, cross-spawn#0.2.9, yeoman-assert#1.0.0, mkdirp#0.5.1, shelljs#0.3.0, cli-table#0.3.1, pretty-bytes#1.0.4, through2#0.6.5, glob#4.5.3, findup-sync#0.2.1, file-utils#0.2.2, dateformat#1.0.11, github-username#1.1.1, lodash#2.4.2, gruntfile-editor#0.2.0, download#3.3.0, mem-fs-editor#1.2.3, sinon#1.15.4, inquirer#0.8.5, yeoman-environment#1.2.7, cheerio#0.18.0)
Anyway, I would try install all deps as local modules.
EDIT:
you should have this directory in you project
node_modules/generator-polymer/node_modules/yeoman-generator/node_modules/download/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/node_modules/find-index
where in tree
glob2base is 0.0.12
glob-stram is 3.1.18
vinyl-fs is 0.3.13
download is 3.3.0
yeoman-generator is 0.18.10
There is a problem with using npm -g unless you can access it without using sudo (ie you have permission to read/write etc in the place where the global modules are installed).
As far as I can work out its bower that is the culprit
The way round the problem is to run npm config edit, and change the prefix value to something you do have access to without sudo. This edits ~/.npmrc file
You then install globally for you.
I was able to fix the issue by deleting the offending directory,
/usr/lib/node_modules/generator-polymer
I do not remember if simply reinstalling generator polymer (sudo npm install -g generator-polymer) fixed the issue completely (let me know and i'll update the answer). I ended up reinstalling everything to make sure any issues were mitigated.
Environment setup
Install node.js. Follow the instructions on their site to install for your OS.
Install Yeoman by typing the command sudo npm install -g yo in your system's console.
The -g installs the package globally, which is why the sudo command is needed (your system may vary).
Next we'll install a couple of Yeoman generators.
Install the polymer generator with the command sudo npm install -g generator-polymer.
(optional) Install the polymer element generator with the command sudo npm install -g generator-element.
This will help with scaffolding out custom Polymer elements.
Starting a new project
With the development environment setup, starting a project is extremely easy.
mkdir my-project
cd my-project
yo polymer
A new polymer project will be setup in the my-project directory using the latest releases of polymer and other dependencies.
Testing a project
Polymer uses the gulp streaming build system. From your project's directory, simply type
gulp serve
See my Polymer 1.0 Notes Google doc.