(generator-polymer) yo polymer fails, cannot find module 'find-index' - node.js

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.

Related

(thread_id_key != 0x7777), function find_thread_id_key, file ../src/coroutine.cc, line 134

i'm working on a vue program, i tried npm run serve then i got this:
66% building 670/715 modules 45 active /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/echarts/lib/chart/graph.js## There is an issue with `node-fibers` ##
`/Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/fibers/bin/darwin-x64-93/fibers.node` is missing.
Try running this to fix the issue: /usr/local/Cellar/node/16.0.0/bin/node /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/fibers/build
Error: Cannot find module '/Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/fibers/bin/darwin-x64-93/fibers'
Require stack:
- /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/fibers/fibers.js
- /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/sass-loader/dist/getSassOptions.js
- /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/sass-loader/dist/index.js
- /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/sass-loader/dist/cjs.js
- /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/loader-runner/lib/loadLoader.js
- /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/loader-runner/lib/LoaderRunner.js
- /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/webpack/lib/NormalModule.js
- /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/webpack/lib/NormalModuleFactory.js
- /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/webpack/lib/Compiler.js
- /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/webpack/lib/webpack.js
- /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/#vue/cli-service/lib/commands/serve.js
- /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/#vue/cli-service/lib/Service.js
- /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/#vue/cli-service/bin/vue-cli-service.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
at Function.Module._load (node:internal/modules/cjs/loader:773:27)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object.<anonymous> (/Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/fibers/fibers.js:14:39)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
at Function.Module._load (node:internal/modules/cjs/loader:828:14)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at require (node:internal/modules/cjs/helpers:93:18)
at getSassOptions (/Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/sass-loader/dist/getSassOptions.js:49:25)
at Object.loader (/Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/sass-loader/dist/index.js:48:51)
at LOADER_EXECUTION (/Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/loader-runner/lib/LoaderRunner.js:119:14)
at runSyncOrAsync (/Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/loader-runner/lib/LoaderRunner.js:120:4)
at iterateNormalLoaders (/Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
69% building 1077/1094 modules 17 active /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/echarts/lib/coord/radar/IndicatorAxis.js## There is an issue with `node-fibers` ##
`/Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/fibers/bin/darwin-x64-93/fibers.node` is missing.
Try running this to fix the issue: /usr/local/Cellar/node/16.0.0/bin/node /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/fibers/build
then i runnode /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/fibers/buildto compile fiber. Afer build i run npm run serve again. then error shows as below:
> omega-fe#1.1.0 serve
> vue-cli-service serve
INFO Starting development server...
42% building 268/307 modules 39 active /Users/bytedance/go/src/code.byted.org/ad/omega_fe/node_modules/core-js/modules/es.array.splice.jsAssertion failed: (thread_id_key != 0x7777), function find_thread_id_key, file ../src/coroutine.cc, line 134.
Abort trap: 6
i have tried reinstall node&&vue. My system is MacOs 11.2.3, node version:16.0.0, npm version: 7.11.0
Any suggesion would be appreciated!
This error is due to the deprecation of node-fibers for node >=16.x released on April 20, 2021.
On the fibers project README:
Update [April 13th, 2021] -- Fibers is not compatible with nodejs v16.0.0 or later. Unfortunately, v8 commit dacc2fee0f is a breaking change and workarounds are non-trivial.
Downgrading node to a lower version (15.14.0) with nvm did the trick on my end
Edit: More detailed answer
I have an exact problem with nuxt project.
My solution is to uninstall from package.json fiber
I also got this error with Nuxt.js and Node.js v16.7.
Nothing worked but downgrading to Node.js v14 or v15.
I had the same issue - the root cause is having the "fibers" module in the project when using node.js v16 or up. Sass-loader relied on fibers until very recent versions, so given your above stacktrace, that's likely the culprit here:
Remove fibers:
npm uninstall --save-dev fibers
"Hard" update sass-loader:
npm uninstall --save-dev sass-loader
npm install --save-dev sass-loader
Wipe & reinstall the node_modules folder:
rm -rf ./node_modules
npm install
Rerun Webpack
If it's still not working after that, try checking package-lock.json for node-fibers, and upgrading any libraries that still depend on it.
I got this error while upgrading to Node 16.x. #wdio/sync package was causing this error as it has a dependency on #types/fibers. Luckily we were not using the async and await . so uninstalling the #wdio/sync package resolved the problem
I ran into this problem because I had updated my NodeJS from v12 to v18. To fix this I had to delete node_modules folder from my project and run npm install.
You can execute:
npm uninstall fibers && rm package-lock.json && rm -R node_modules && npm install

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.

Installing node-sass on ubuntu 18.04 returns error

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

var mqtt = require('mqtt'); resulting in error

I have installed 'node.js' and then executed 'npm install mqtt' from 'node.js' command line to install 'mqtt.js'. Now to test 'mqtt client' I am trying to execute :
var mqtt = require('mqtt');
which results in error saying:
"Error: Cannot find module 'mqtt'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at repl:1:12
at REPLServer.self.eval (repl.js:110:21)
at repl.js:249:20
at REPLServer.self.eval (repl.js:122:7)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)"
First, you need to add the MQTT library.
If you have npm package manager installed on the server, you should run npm install mqtt --save
For detailed information: https://www.npmjs.com/package/mqtt
For requiring Node.js module, refer to this tutorial which is pretty detailed.
http://www.bennadel.com/blog/2169-where-does-node-js-and-require-look-for-modules.htm
By the way, createClient() has been deprecated by mqtt module, use connect() instead.
If you ever want to test your MQTT client with a ready online broker, try http://www.robomq.io.
This is a common issue that Node developers face. While working on Unix systems, sometimes it may not allow you to install such packages. For that, you will need sudo permissions. Sometimes, the package is installed but only in your local modules, and when you try to import it from outside of the directory, the error occurs. Sometimes, your compiler read your dependencies, but not able to find this package in that, at that time also you face this error.
Anyways, don't worry. You just have to follow some steps below.
A best practice is to initialize your project using npm init before starting development. This will initialize your project and generate package.json file.
Then, if you want any library as dependencies, try --save with npm install command. This will save your dependency in package.json file.
e.g. npm install mqtt --save
If any package is not found after installing, install it globally by -g flag.
Globally installed packages will be accessible within your system. e.g. npm install mqtt -g.
Note: Unix system needs SUDO permission for installing it globally.
I hope this will help you.
When you use the command line for node.js, it searches for node modules that are installed globally which is usually in the directory /usr/lib/node_modules in Linux machines.
When you run npm install, the node modules are installed locally in the same directory where the node terminal was launched.
If you want to access node modules in the node terminal, you need to run npm install mqtt -g where -g stands for global installation.
Usually Linux machines don't allow normal users to access /usr/lib/node_modules so it'll be better to run it as sudo npm install mqtt -g

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