NodeJS error when trying to run Polymer CLI - node.js

I get the following error running the polymer cli.
$ polymer
module.js:327
throw err;
^
Error: Cannot find module '..'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at /usr/local/lib/node_modules/polymer-cli/bin/polymer.js:19:36
at /usr/local/lib/node_modules/polymer-cli/node_modules/resolve/lib/async.js:46:14
at process (/usr/local/lib/node_modules/polymer-cli/node_modules/resolve/lib/async.js:173:43)
at ondir (/usr/local/lib/node_modules/polymer-cli/node_modules/resolve/lib/async.js:188:17)
at load (/usr/local/lib/node_modules/polymer-cli/node_modules/resolve/lib/async.js:69:43)
at onex (/usr/local/lib/node_modules/polymer-cli/node_modules/resolve/lib/async.js:92:31)
I've tried node 4.x and 6.x
I've also tried to install different versions of polymer-cli, 0.8 and 0.10
I'm running node on Ubuntu 16.04.
Does anyone know what issue I'm running into or how I can resolve this?

Ok wow after quite a lot of digging and searching, I found the answer. Turns out I had previously tried to install polymer-cli using the default ubuntu package. This installed it in a separate location, also on the global path.
When I remove NodeJS and NPM to install the latest version via the PPA, the original polymer-cli was still left on my path. So when I then installed the latest polymer-cli, this was correctly installed, but was never the one being executed since the old one was found on the path first.
I manually deleted all node_modules folders and after doing that I was able to install and run the correct version of polymer-cli, and it now works perfectly fine.

Related

Error running npm command on Windows: graceful-fs

I have a ReactJS project and I was trying to use some of the PrimeReact components. At some point, I faced an error (can't remember exactly which one) and I tried to run an older version of NPM in a copy of my main directory.
Now, I get this error every time, even when I run npm command.
I've already tried to delete my node_modules folder, delete my project and clone it back from GitHub and also to reinstall NodeJS several times. I don't know what to do!
I have Windows 10 and I'm using NodeJS v12.16.0.
Thanks to anyone that offers some help
Update: I have never installed gulp. I suppose that maybe some dependency is using it but, because I can't run any npm command, I can't remove them D:
The error:
C:\Users\Carlos>npm
evalmachine.<anonymous>:35
} = primordials;
^
ReferenceError: primordials is not defined
at evalmachine.<anonymous>:35:5
at Object.<anonymous> (C:\Users\Carlos\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-client\node_modules\graceful-fs\fs.js:12:1)
at Module._compile (internal/modules/cjs/loader.js:1157:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
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> (C:\Users\Carlos\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-client\node_modules\graceful-fs\graceful-fs.js:3:27)
at Module._compile (internal/modules/cjs/loader.js:1157:30)
It might be an error related with gulp and node v12 conflict. If you have the gulp installed globally in your environment and you can uninstall without problems, you can try it. To help with commands, check if you have the gulp installed, typing this in your command line interface:
gulp -v
Uninstall your version:
npm uninstall -g gulp

Angular project not working after installation of newer version of node.js

I am working with an angular 7 project.
initially, I was using node version 10 and by mistake, I upgrade the node to version 12.
after that, I tried to compile my Angular 7 project it is the thrwing error. I again reinstall the older version but still, it is throwing the error as below.
ERROR in ./src/app/pages/pages.component.scss
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Cannot find module 'node-sass'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.sassLoader (E:\QiwkCollaborator\QiwkCollaboratorTool\node_modules\sass-loader\lib\loader.js:46:72)
ERROR in ./node_modules/ionicons/scss/ionicons.scss (./node_modules/#angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./node_modules/ionicons/scss/ionicons.scss)
I don't have any idea how to resolve this error. any suggestions, please.
Thanks in Advance!
Currently having same issue, solution I am implementing is to use docker to run the older version of node that is compatible with the node-sass or install a newer version of the package.

Can't Install Browser Sync on Mac

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

Node Module Version Mismatch: Expected 50

I've had this problem where, from a brand new installation of Node and npm, the serial port package won't load with the following error in the Hello World Electron package:
I am on Node version 6.6.0 and NPM version 3.10.7 and OS X 10.11.6.
I looked to see if I was somehow out of date, but looking at this list, I can't find anything that has a module version of 50. Is this a bug?
I have tried npm rebuild, as well as removing modules and reinstalling, but no dice.
Update: even though when I run node -v it prints v6.6.0, running process.versions.node in the web console gives me v6.5.0. What's going on here?
This is a known issue which is caused by the serialport module using native code that is built for a different version of Node. You can read a bit more about addons here, if you're interested; they're just modules written in C/C++ that can interface with Node so the module can interface with the hardware more easily.
The solution proposed by that issue is this:
npm rebuild --runtime=electron --target=1.2.5 --disturl=https://atom.io/download/atom-shell --build-from-source
If you've not already installed electron-rebuild, that might be helpful to ensure that the rebuilding process works correctly:
npm install --save-dev electron-rebuild
even though when I run node -v it prints v6.6.0, running process.versions.node in the web console gives me v6.5.0. What's going on here?
Electron uses its own version of Node that isn't connected to your system Node installation (see the homepage to view the Node version that the latest Electron uses, or use process.versions.node, like you did in the question).
You could try an older version (perhaps 1.1.0, which uses Chrome 50?) in case that is the cause of the issue.
In my case the error was:
App threw an error during load
Error: Module version mismatch. Expected 50, got 48.
at Error (native)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
at Object.Module._extensions..node (module.js:583:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/myapp/node_modules/sqlite3/lib/sqlite3.js:4:15)
After rebuilding error was fixed:
npm install --save-dev electron-rebuild
npm rebuild --runtime=electron --target=1.4.3 --disturl=https://atom.io/download/atom-shell --build-from-source

Cannot find module 'readable-stream' when using npm

I installed nodejs and am trying to use npm on my Windows machine. I downloaded all the files from nodejs website. I tried to install the latest 4.4.2 version or 5.10.1 version, but I always got error Cannot find module 'readable-stream' when I tried to run commands using npm.
C:\Users\Ealon>node -v
v5.10.1
C:\Users\Ealon>npm -v
module.js:341
throw err;
^
Error: Cannot find module 'readable-stream'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\Users\Ealon\AppData\Roaming\npm\node_modules\npm\node
modules\npmlog\node_modules\are-we-there-yet\index.js:2:14)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
I tried to reinstall it again and again, still could not fix this problem. And the answers in another similar question do not help because I always got error when I tried to run any command using npm. Any help is appreciated. Thanks!
Judging from the line C:\Users\Ealon\AppData\Roaming\npm\node_modules\npm\node
modules\npmlog\node_modules\are-we-there-yet\index.js:2:14 in the stack trace, I believe that you had a global installation of npm which internally had a dependency on are-we-there-yet, which I confirmed has a dependency on readable-stream.
The global installation of npm appears to have been borked, and are-we-there-yet couldn't resolve access to the readable-stream module for some reason (bad install?).
This wasn't getting fixed by re-installing node, which by default installs npm into program files (path similar to C:\Program Files\nodejs\node_modules\npm). I think the global version was getting run, but the version inside program files should be getting run, so wiping out the global installation of npm should hopefully resolve the issue.
I somehow fixed this issue by upgrading npm in Intellij IDEA.
But I still want an expnalation why that problem in my question happened. I will not mark this as the answer.
No need to uninstall node js. When I tried to update my node version, I got this issue & resolved the the same by following below step -
Go to control panel --> uninstall Programs --> select node.js
and click repair.
Had this issue on a Mac. I cloned a project multiple times to handle different branches in parallel. Only one of my cloned repos started having this same issue when I ran npm start. I deleted the repo, cloned it again and nom was running fine again in that repo. Doesn't sound like a global issue to me. No idea what went wrong.

Resources