NPM is completely ignoring globally installed packages - node.js

I'm having a problem with installing packages locally, where globally installed packages are available. There seems to be a problem with the include path, but I am not sure what this is causing.
System : Mac OS X
Node : 8.3.1
NPM : 5.0.4
Output for npm list -g --depth=0
/usr/local/lib
+-- node-gyp#3.6.2
+-- node-sass#4.5.3
+-- npm#5.0.4
`-- npm-check#5.4.4
When I'm trying to install it first mentions node-gyp which is installed globally, unlike the warning. And after that it fails with node-sass which is also installed globally.
jurriendokter$ npm install
npm WARN prefer global node-gyp#3.6.1 should be installed with -g
> node-sass#4.5.2 install /Users/jurriendokter/Development/holland-toolkit/node_modules/node-sass
> node scripts/install.js
module.js:487
throw err;
^
Error: Cannot find module 'extend'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/jurriendokter/Development/holland-toolkit/node_modules/node-sass/node_modules/request/index.js:17:29)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass#https://registry.npmjs.org/node-sass/-/node-sass-4.5.2.tgz (node_modules/node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass#4.5.2 install: `node scripts/install.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
added 291 packages in 7.829s
I have reinstalled node on mac osx, checked npm doctor and everything, but I'm at a total loss.
How can I fix this?

I managed to fix this using the following procedure.
npm cache clear --force
rm -rf node_modules
rm package-lock.json
npm install
npm update
Mind that this does not solve the warning: npm WARN prefer global node-gyp#3.6.2 should be installed with -g but it allows me to install and run my scripts again.

Related

"Syntax error unexpected token ..." when running pm2 on amazon linux

I have installed nodejs that is provided by amazon-extras:
sudo amazon-linux-extras install -y epel
yum install -y nodejs
node --version
Let's install pm2 now:
sudo npm install pm2#latest -g
/usr/bin/pm2 -> /usr/lib/node_modules/pm2/bin/pm2
/usr/bin/pm2-dev -> /usr/lib/node_modules/pm2/bin/pm2-dev
/usr/bin/pm2-docker -> /usr/lib/node_modules/pm2/bin/pm2-docker
/usr/bin/pm2-runtime -> /usr/lib/node_modules/pm2/bin/pm2-runtime
/usr/lib
└── pm2#4.5.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#~2.1.2 (node_modules/pm2/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN ws#7.2.5 requires a peer of bufferutil#^4.0.1 but none was installed.
npm WARN ws#7.2.5 requires a peer of utf-8-validate#^5.0.2 but none was installed.
That seems OK . But then running pm2 is not so happy:
$ pm2
/usr/lib/node_modules/pm2/node_modules/chalk/source/index.js:103
...styles,
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/lib/node_modules/pm2/constants.js:10:14)
What is the issue and workaround for this?
This is highly likely to be due to the default version of node on amazon linux is like incredibly dated
$ node --version
v6.17.1
When I figure out how to get a bronze age (vs stone age) node version this answer will be updated.
Run compatible pm2 version, this worked for me:
npm install pm2#^3
The version of node on Amazon Linux is pretty outdated.
Try updating it like this:
sudo npm install n -g
sudo n latest

Cannot find module './build/Debug/DTraceProviderBindings'

I know this question has been asked lots of times like
here and here.
I have tried all suggestions on these links and more..
I tried installing the latest bunyan
sudo npm install bunyan#1.8.12 --unsafe-perm=true --allow-root
I installed and rebuilt latest dtrace-provider
sudo npm install dtrace-provider#0.8.7 --unsafe-perm=true --allow-root
sudo npm rebuild dtrace-provider#0.8.7 --unsafe-perm=true --allow-root
it built the module successfully.
+ NODE_GYP_STATUS=0
+ [[ 0 -ne 0 ]]
+ exit 0
touch Release/obj.target/ndtp.stamp
npm WARN swaggerize-express#4.0.5 requires a peer of express#^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN tr-stack#1.0.0 No repository field.
+ dtrace-provider#0.8.7
In spite of that I am still getting this error:
Error: Cannot find module './build/Release/DTraceProviderBindings'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
at Function.Module._load (internal/modules/cjs/loader.js:529:25)
at Module.require (internal/modules/cjs/loader.js:657:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/Users/yogeshsingh/TradeRev/code/tr-stack/node_modules/vogels/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (internal/modules/cjs/loader.js:721:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
node version and npm version are as follows:
node: v11.6.0
npm : 6.5.0

Meteor Deploy Error

Hi there I am trying to deploy my meteor app, I am using meteor up. Meteor setup works fine. I have update node and npm on both my local and server machines. ruining node version node 4.6.0 and npm 3.10.9 and the latest version on meteor. But i keep getting this log error.
[40.69.194.127] => Starting meteor app on port:80
[40.69.194.127] at wrapPathFunction (/bundle/bundle/programs/server/mini-files.js:77:10
at Object.<anonymous> (/bundle/bundle/programs/server/mini-files.js:108:24)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/bundle/bundle/programs/server/boot.js:9:13)
at Module._compile (module.js:456:26)
npm WARN deprecated This version of npm lacks support for important features,
npm WARN deprecated such as scoped packages, offered by the primary npm
npm WARN deprecated registry. Consider upgrading to at least npm#2, if not the
npm WARN deprecated latest stable version. To upgrade to npm#2, run:
npm WARN deprecated
npm WARN deprecated npm -g install npm#latest-2
npm WARN deprecated
npm WARN deprecated To upgrade to the latest stable version, run:
npm WARN deprecated
npm WARN deprecated npm -g install npm#latest
npm WARN deprecated
npm WARN deprecated (Depending on how Node.js was installed on your system, you
npm WARN deprecated may need to prefix the preceding commands with `sudo`, or if
npm WARN deprecated on Windows, run them from an Administrator prompt.)
npm WARN deprecated
npm WARN deprecated If you're running the version of npm bundled with
npm WARN deprecated Node.js 0.10 LTS, be aware that the next version of 0.10 LTS
npm WARN deprecated will be bundled with a version of npm#2, which has some small
npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
npm WARN deprecated semver behavior.
npm WARN package.json meteor-dev-bundle#0.0.0 No description
npm WARN package.json meteor-dev-bundle#0.0.0 No repository field.
npm WARN package.json meteor-dev-bundle#0.0.0 No README data
npm WARN cannot run in wd meteor-dev-bundle#0.0.0 node npm-rebuild.js (wd=/bundle/bundle/pr
assert.js:93
throw new assert.AssertionError({
^
AssertionError: "undefined" === "function"
at wrapPathFunction (/bundle/bundle/programs/server/mini-files.js:77:10)
at Object.<anonymous> (/bundle/bundle/programs/server/mini-files.js:108:24)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/bundle/bundle/programs/server/boot.js:9:13)
at Module._compile (module.js:456:26)
My server is on azure and it is a Ubuntu 14 machine.
Can some on please help me on this i have stuck on this a long time now.
Thanks
To fix this, you'll need to change mup.js settings to use the docker image as below:
{
meteor: {
dockerImage: 'abernix/meteord:base',
// ...
},
}
For more details, you can check the answers of #abernix inside this link: https://github.com/meteor/meteor/issues/7475.

npm install: Error : Cannot find module 'tough-cookie'

I have removed and reinstalled node.js many times
> node -v
4.5.0
> npm -v
3.3.6
Once I run the command npm install request I get the following error :
Error: Cannot find module 'tough-cookie'
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 Object.<anonymous> (C:\Users\Generic User\AppData\Roaming\npm\node_modules\npm\node_modules\request\lib\cookies.js:3:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Generic User\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "request"
npm ERR! node v4.5.0
npm ERR! npm v3.3.6
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'tough-cookie'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
You probably will tell me to run
> npm update -g npm
I get the same error for this command too.
It looks like your version 3 npm install is broken, for some reason. It'd be interesting to know whether this path exists:
C:\Users\Generic User\AppData\Roaming\npm\node_modules\npm\node_modules\request\node_modules\tough-cookie
and whether it contains a valid package, etc.
With your npm v 3 install, broken, none of the npm install or update commands will work (as they'll need the request module). However, you might be able to roll back npm - as version 4.5.0 of Node.js installs npm version 2.15.9 and it will still be there:
> npm uninstall -g npm
That should leave you with:
> npm -v
2.15.9
Before re-installing npm v 3, clear the cache:
> npm cache clear
> npm install -g npm
However, before you re-install version npm v 3, it would be interesting to see if you are able to install request with npm v 2.
In my case it was a .lock file that caused this error, deleting the file fixed it. Same problem and solution was reported here: https://github.com/sass/node-sass/issues/2019
Is there a package.json file in the folder you are running node from?
If there is a package.json, then running :
npm install request
will not have the desired effect, in fact npm will just try and install whatever module is described in package.json
Have you tried npm install tough-cookie
it has worked for me
its browser issue ... please try to open it in chrome incognito windows or firefox private window and delete cookies

npm 3.5.4: EBUNDLEOVERRIDE during update causes npmlog error

Upgraded to Node 5.4.0 via 'brew upgrade,' and then ran 'npm update -g,' which upgraded to npm 3.5.4. npm update finished with warnings:
/usr/local/lib
└── npm#3.5.4
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > init-package-json with new installed version
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > node-gyp with new installed version
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > npm-install-checks with new installed version
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > npmlog with new installed version
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > read-package-json with new installed version
Running 'npm update -g' (or any other npm command) now throws npmlog errors:
module.js:328
throw err;
^
Error: Cannot find module 'npmlog'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:20:13
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:76:3)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
It's not clear to me why the override is happening, or how to point npm to the logs again. Appreciate any thoughts.
Looks like brew reinstall node is the least-destructive way to resolve this. Will install node 3.3.12 while leaving everything else in place:
$ brew reinstall node
==> Reinstalling node
==> Downloading https://homebrew.bintray.com/bottles/node-5.4.1.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/node-5.4.1.yosemite.bottle.tar.gz
==> Pouring node-5.4.1.yosemite.bottle.tar.gz
==> Caveats
Please note by default only English locale support is provided. If you need
full locale support you should:
`brew reinstall node --with-full-icu`
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
🍺 /usr/local/Cellar/node/5.4.1: 2,827 files, 34.2M
$ npm outdated --global
Package Current Wanted Latest Location
npm 3.3.12 3.5.4 3.5.3
I completely reinstalled npm which seemed to be the only solution I could find for this error. It fixed it for me.

Resources