This question already has answers here:
"message failed to fetch from registry" while trying to install any module
(15 answers)
Closed 8 years ago.
I am starting my first Node.js server. I am attempting to follow a tutorial in Node.js.
Having installed Node.js and executed npm install, the next instruction is to start the server by running node server.js which generates the following error:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'express'
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/sisko/Desktop/ExerciseFiles/01/03/start/server.js:1:77)
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 Array.0 (module.js:479:10)
sisko#VirtualBox:~/Desktop/ExerciseFiles/01/03/start$
It seemed it needed a module called express so I looked around and found the npm install express command which should fix the issue. However, I get the following error:
sisko#VirtualBox:~/Desktop/ExerciseFiles/01/03/start$ npm install express
npm http GET https://registry.npmjs.org/express
npm ERR! Error: failed to fetch from registry: express
npm ERR! at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR! at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
npm ERR! at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
npm ERR! at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
npm ERR! at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58)
npm ERR! at Request.emit (events.js:88:20)
npm ERR! at ClientRequest.<anonymous> (/usr/lib/nodejs/request/main.js:412:12)
npm ERR! at ClientRequest.emit (events.js:67:17)
npm ERR! at HTTPParser.onIncoming (http.js:1261:11)
npm ERR! at HTTPParser.onHeadersComplete (http.js:102:31)
npm ERR! You may report this log at:
npm ERR! <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR! reportbug --attach /home/sisko/Desktop/ExerciseFiles/01/03/start/npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.2.0-52-generic
npm ERR! command "node" "/usr/bin/npm" "install" "express"
npm ERR! cwd /home/sisko/Desktop/ExerciseFiles/01/03/start
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: express
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/sisko/Desktop/ExerciseFiles/01/03/start/npm-debug.log
npm not ok
Seems like it's a SSL certificate issue with the repository, because it worked with HTTP but not HTTPS.
For troubleshooting only
To troubleshoot, on a sandbox where you're okay running untrusted code, you can confirm this by trying the repository under HTTP this insecure hack: running npm config set registry http://registry.npmjs.org/ (or whaterver repo) then npm install express.
If that worked when the HTTPS doesn't, then it's probably an SSL issue.
Please do not use this insecure config as a fix. It's not a fix.
Installing from HTTP opens you up to running code from a malicious source.
The fix is to update node/npm versions and/or fix the SSL.
This helps as an alternative solution to accepted answer:
npm config set strict-ssl false
The problem with npm is that the default registry ssl certificate is not recognized properly.
Related
I have a problem with install puppeteer.
I set Visual Code in firewall
When I write npm install puppeteer terminal show me this ERROR :
ERROR: Failed to set up Chromium r869685! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
Error: Download failed: server returned code 403. URL: https://storage.googleapis.com/chromium-browser-snapshots/Win/869685/chrome-win.zip
at D:\webs\scraper\node_modules\puppeteer\lib\cjs\puppeteer\node\BrowserFetcher.js:366:27
at ClientRequest.requestCallback (D:\webs\scraper\node_modules\puppeteer\lib\cjs\puppeteer\node\BrowserFetcher.js:492:13)
at Object.onceWrapper (events.js:483:26)
at ClientRequest.emit (events.js:376:20)
at HTTPParser.parserOnIncomingClient (_http_client.js:647:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
at TLSSocket.socketOnData (_http_client.js:515:22)
at TLSSocket.emit (events.js:376:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
npm WARN enoent ENOENT: no such file or directory, open 'D:\webs\scraper\package.json'
npm WARN scraper No description
npm WARN scraper No repository field.
npm WARN scraper No README data
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! puppeteer#9.1.1 install: node install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the puppeteer#9.1.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\AA\AppData\Roaming\npm-cache\_logs\2021-05-28T13_57_47_494Z-debug.log
Thanks for help.
Google is blocking you to download.
Try this :-
set environment variable PUPPETEER_DOWNLOAD_HOST to http://storage.googleapis.com
I'm doing a unit testing for my javascript codes. I prefer to use a headless browser for easier running. It goes well when I installed some dependencies but when I install phantomjs, it has an error.
C:\Phantomjs>npm install -g phantomjs npm WARN deprecated
phantomjs#2.1.7: Package renamed to phantomjs-prebuilt. Plea se update
'phantomjs' package references to 'phantomjs-prebuilt' npm WARN
deprecated node-uuid#1.4.8: Use uuid module instead npm WARN
deprecated tough-cookie#2.2.2: ReDoS vulnerability parsing Set-Cookie
h ttps://nodesecurity.io/advisories/130
C:\Users.ra\AppData\Roaming\npm\phantomjs ->
C:\Users.ra\AppDa
ta\Roaming\npm\node_modules\phantomjs\bin\phantomjs
phantomjs#2.1.7 install C:\Users.ra\AppData\Roaming\npm\node_modules\ phantomjs
node install.js
Considering PhantomJS found at
C:\Users.ra\AppData\Roaming\npm\phantomj s.CMD Looks like an
npm install -g on windows; skipping installed version. Downloading
https://github.com/Medium/phantomjs/releases/download/v2.1.1//phanto
mjs-2.1.1-windows.zip Saving to
C:\Users.ra\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-wind
ows.zip Using proxy http://.ra:******#proxy:3128/ Receiving...
Error making request. Error: tunneling socket could not be
established, statusCode=502
at ClientRequest.onConnect (C:\Users.ra\AppData\Roaming\npm\node_mo
dules\phantomjs\node_modules\tunnel-agent\index.js:165:19)
at Object.onceWrapper (events.js:320:30)
at emitThree (events.js:135:13)
at ClientRequest.emit (events.js:216:7)
at Socket.socketOnData (_http_client.js:470:11)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at addChunk (_stream_readable.js:264:12)
at readableAddChunk (_stream_readable.js:251:11)
at Socket.Readable.push (_stream_readable.js:209:10)
Please report this full log at https://github.com/Medium/phantomjs npm
WARN Error: EPERM: operation not permitted, scandir
'C:\Users.ra\Ap
pData\Roaming\npm\node_modules\phantomjs\node_modules\dashdash\node_modules'
npm WARN { Error: EPERM: operation not permitted, scandir
'C:\Users.ra
\AppData\Roaming\npm\node_modules\phantomjs\node_modules\dashdash\node_modules'
npm WARN stack: 'Error: EPERM: operation not permitted, scandir
\'C:\Users\p
ardillo.ra\AppData\Roaming\npm\node_modules\phantomjs\node_modules\dashda
sh\node_modules\'', npm WARN errno: -4048, npm WARN code:
'EPERM', npm WARN syscall: 'scandir', npm WARN path:
'C:\Users\.ra\AppData\Roaming\npm\node_modules\p
hantomjs\node_modules\dashdash\node_modules' } npm ERR! code
ELIFECYCLE npm ERR! errno 1 npm ERR! phantomjs#2.1.7 install: node
install.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the
phantomjs#2.1.7 install script. npm ERR! This is probably not a
problem with npm. There is likely additional log ging output above.`
What should I do?
The simplest installation method is
Install NodeJS
Using Node's package manager install phantomjs: npm -g install phantomjs-prebuilt
After installation, you may use phantom as simple as:
driver = webdriver.PhantomJS() # or add to your PATH
driver.set_window_size(1024, 768) # optional
driver.get('https://google.com/')
driver.save_screenshot('screen.png') # save a screenshot to disk
sbtn = driver.find_element_by_css_selector('button.gbqfba')
sbtn.click()
If your system path environment variable isn't set correctly, you'll need to specify the exact path as an argument to webdriver.PhantomJS(). Replace this:
driver = webdriver.PhantomJS() # or add to your PATH
... with the following:
driver = webdriver.PhantomJS(executable_path='/usr/local/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs')
References:
How do I set a proxy for phantomjs/ghostdriver in python webdriver?
https://dzone.com/articles/python-testing-phantomjs
Try run npm install phantomjs-prebuilt
phantomjs name changed to phantomjs-prebuilt on Pre-2.0 version release.
Source: view this link for detailed description of the name change.
I'm trying to encode a NetCDF file in Node.js program, by using the netcdf(https://www.npmjs.com/package/netcdf) library.
Now, once I run a program, I get an error below.
C:\app [master +2 ~1 -0 !]> npm start
> spaceapps#1.0.0 start C:\app
> node server.js
C:\app\node_modules\text-encoding\lib\encoding.js:979
throw TypeError('Called as a function. Did you forget \'new\'?');
^
TypeError: Called as a function. Did you forget 'new'?
at TypeError (native)
at Object.TextDecoder (C:\app\node_modules\text-encoding\lib\encoding.js:979:13)
at Object.<anonymous> (C:\app\node_modules\netcdf\util\readbinary.js:4:40)
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)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\app\node_modules\netcdf\util\type.js:4:14)
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files (x86)\\Nodist\\v\\nodev5.9.1\\node.exe" "C:\\Program Files (x86)\\Nodist\\bin\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v5.9.1
npm ERR! npm v3.8.7
npm ERR! code ELIFECYCLE
npm ERR! spaceapps#1.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the spaceapps#1.0.0 start script 'node server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the spaceapps package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs spaceapps
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls spaceapps
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\app\npm-debug.log
C:\app [master +3 ~1 -0 !]>
It seems there is an error in a library.
I appreciate if someone tells me a solution for it.
As the developer said, He has no plans in the short or medium term to continue development, so you could consider use netcdfjs, that it's a javascript library that allows to read NetCDF v3 files. Because it's a NodeJS package you can run it server side, and for regular size files you can read it online, here you have an example.
My newest npm constantly crashes, when I trying to install some npm package (npm install). I have to repeat this process for example for 5 times before I install all dependencies and even then, It sometimes miss some nested dependencies. So I have to go through the tree and run npm install again.
I tried to use this but with no luck. I'am not behind a proxy. Where should be problem? Installing is taking so long, and my internet connection is not slow.
npm config set registry http://registry.npmjs.org/
c:\work\projects\java\project\frontend-src\node_modules\gulp\node_modules\orchestrator>npm install
npm ERR! fetch failed http://registry.npmjs.org/event-stream/-/event-stream-3.1.7.tgz
npm ERR! fetch failed http://registry.npmjs.org/rcloader/-/rcloader-0.1.2.tgz
npm ERR! fetch failed http://registry.npmjs.org/debug/-/debug-2.1.0.tgz
npm ERR! fetch failed http://registry.npmjs.org/rcloader/-/rcloader-0.1.2.tgz
npm ERR! fetch failed http://registry.npmjs.org/debug/-/debug-2.1.0.tgz
npm ERR! fetch failed http://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz
npm ERR! fetch failed http://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz
npm ERR! fetch failed http://registry.npmjs.org/from/-/from-0.1.3.tgz
npm ERR! fetch failed http://registry.npmjs.org/rcloader/-/rcloader-0.1.2.tgz
npm ERR! network read ECONNRESET
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Apps\\nodejs\\\\node.exe" "C:\\Apps\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd c:\work\projects\java\project\frontend-src\node_modules\gulp\node_modules\orchestrator
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! syscall read
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! not ok code 0
I don't know how it is possible but these problems disappered after I switched to WIFI on my laptop. I have MSI GT70 which has Killer e2200 Atheros gigabit ethernet. It is likely that cause of this problems is driver/software for manage network traffic (Qualcomm bigfoot) which prefer packets of games. I can't tell for sure because I didn't find any other driver for my configuration.
I try to install node.js modules using:
npm install express
but I get this error:
npm http GET https://registry.npmjs.org/express
npm ERR! TypeError: Request path contains unescaped characters.
npm ERR! at Agent.request (_http_agent.js:264:11)
npm ERR! at TunnelingAgent.exports.request (http.js:52:22)
npm ERR! at TunnelingAgent.createSocket (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/tunnel-agent/index.js:117:25)
npm ERR! at TunnelingAgent.createSecureSocket [as createSocket] (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/tunnel-agent/index.js:184:41)
npm ERR! at TunnelingAgent.addRequest (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/tunnel-agent/index.js:80:8)
npm ERR! at new ClientRequest (_http_client.js:112:16)
npm ERR! at Agent.request (_http_agent.js:279:10)
npm ERR! at Object.exports.request (https.js:130:22)
npm ERR! at Request.start (/usr/local/lib/node_modules/npm/node_modules/request/index.js:594:30)
npm ERR! at Request.end (/usr/local/lib/node_modules/npm/node_modules/request/index.js:1186:28)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Linux 3.6.11-7.fc16.x86_64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "express"
npm ERR! cwd /usr/local/src/node
npm ERR! node -v v0.11.5-pre
npm ERR! npm -v 1.3.5
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /usr/local/src/node/npm-debug.log
npm ERR! not ok code 0
May be happening I use a proxy I set it up this way to allow downloads from ips outside my network
export https_proxy='http://172.21.0.12:3128'
I hope you can help me
Set proxy from commandline.
npm config set proxy http://proxydomain:port/
If error occur yet, additional try next.
npm config set registry http://registry.npmjs.org/
These work for me.
(ref http://sushichop.blogspot.jp/2013/01/npm-install.html)
Though late enough, I've bumped into this too after updating nodejs (to 4.1.1) and npm (to something like 1.4.x) on Linux.
I've tried the suggested solution, but changing the registry entry did not help in all cases.
Lastly, having decided to reinstall npm, I found this update source [on npm github][1]
curl -L https://www.npmjs.org/install.sh | sh
which updated my npm to 3.3.8 and all related package installation troubles have been blown away.