Unable to install npm package due to encoded url - windows

So I recently got a Windows laptop at work, trying to set up my dev environment and I am getting a strange issue when trying to install our private gitlab npm packages.
I try npm install and it says it cannot find the package even though it has been published to our private registry. This seems to only be happening on my windows machine. The package can be found no problem on my macbook.
npm i
npm ERR! code E404
npm ERR! 404 Not Found - GET https://gitlab.orgname.com/api/v4/projects/118/packages/npm/#integrations%2fcommon-ui
npm ERR! 404
npm ERR! 404 '#integrations/common-ui#^1.0.4' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jack.lovett\AppData\Local\npm-cache\_logs\2022-12-13T10_08_06_142Z-debug-0.log
It seems that / in the path is being encoded to %2f so then it can't find the package anymore.
I can't find any help online for this issue so any ideas would be greatly appreciated.

The %2f part in the url seemed to not be relevant and just caused me to go down a rabbit hole of unrelated issues.
What seemed to be the problem was that i did not have NVM correctly set to my PATH in my environment variables.
When adding to path I added the location of my /node.js directory in /"Program Files"/node.js. This then added to my path the correct node version used by nvm.
I then attempted to authenticate with our private package registry again and it all worked as expected.

Related

Error during the build on the Plesk server with my Nuxt app

I have a Vue Storefront 2 project with Magento 2 as it CMS. Locally everything runs fine.
When I try to run NPM install on my Plesk server before I can build and deploy it, it gives the following error:
npm ERR! code 1
npm ERR! path /var/www/vhosts/vuestorefront2.dev/node_modules/deasync
npm ERR! command failed
npm ERR! command sh -c node ./build.js
npm ERR! linux-x64-node-16 exists; testing
npm ERR! Problem with the binary; manual build incoming
npm ERR! stdout=
npm ERR! err=Error: Command failed: /opt/plesk/node/16/bin/node quick-test.js
npm ERR! /var/www/vhosts/vuestorefront2.dev/node_modules/bindings/bindings.js:135
I have tried to remove all references of deasync in my package-lock.json.
Even though NPM install then runs and allows me to build to project afterwards, it did not load any products from Magento anymore on the deployed instance. Locally I do however fetch and display products succesfully.
When you have an issue regarding a build remotely, the first step is usually to build it locally (with something like npm run build, then run it locally npm run start) to be sure if it's a Nuxt issue or a hosting/platform issue.
Here, it looked like OP could fix his problem by forcing a specific endpoint to use the production URL. Maybe he is lacking some local server.
This fixed the issue
publicRuntimeConfig: {
middlewareUrl: process.env.NODE_ENV === "production"
? "https://example.com/api/" // Your production URL
: "http://localhost:3000/api/",
}

Running Svelte on Windows 10 - 'sirv' is not recognized as a command

I'm trying to get started with Svelte. All guides I've found list two commands as all that's required:
npm install
npm run dev
However, in Windows 10, with a fresh install of Node 12.16.3 LTS and NPM 6.14.4 (installed with NVM-Windows after uninstalling NodeJS completely, per this guide), once I hit npm run dev, I get the following errors:
$ npm run dev
> svelte-app#1.0.0 dev C:\Users\Matthew\Desktop\SvelteTest
> rollup -c -w
'rollup' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! svelte-app#1.0.0 dev: `rollup -c -w`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the svelte-app#1.0.0 dev 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\Matthew\AppData\Roaming\npm-cache\_logs\2020-05-23T02_58_39_101Z-debug.log
"Hmm... Okay, that's weird, since every tutorial I've watched and guide I've read has this including in npm install, but, no worries, I'll just install rollup," I think to myself... A quick npm install -g rollup later, and the error is fixed! Good start. Sadly, this doesn't last too long, since now I run into the following issue:
$ npm run dev
> svelte-app#1.0.0 dev C:\Users\Matthew\Desktop\SvelteTest
> rollup -c -w
rollup v2.10.7
bundles src/main.js → public\build\bundle.js...
LiveReload enabled
created public\build\bundle.js in 338ms
> svelte-app#1.0.0 start C:\Users\Matthew\Desktop\SvelteTest
> sirv public "--dev"
'sirv' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! svelte-app#1.0.0 start: `sirv public "--dev"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the svelte-app#1.0.0 start 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\Matthew\AppData\Roaming\npm-cache\_logs\2020-05-23T03_00_53_008Z-debug.log
This time, no amount of npm install -g sirv will work. Is there a step I'm missing to getting this project to run?
Some notes:
I can get it to work in WSL Ubuntu 18.04 LTS, but would prefer not to have to use WSL if at all possible.
I don't see anything anywhere online that says that Windows isn't supported... is it not? Am I not looking hard enough?
When I run npm install -g rollup, I see the following warnings:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#~2.1.2 (node_modules\rollup\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
I assume that, since this is listed as an optional dependency, it is not the source of the issue. Nonetheless, it feels silly not to bring it up — just in case. These same warnings appear during npm install.
The files npm-cahce\_logs\[datetime]-debug.log don't contain any usefull information as far as I can tell, they simply say, "sirv public "--dev" → Failed to start exec script" followed by a stack-trace.
After the second error, the program does not automatically terminate — but it is not available at localhost:5000.
I had my files in OneDrive for a while (they're now on my Desktop, which is not synced or tracked in any way), and OneDrive was upset about the files in node_modules/.bin, saying that they "couldn't be synced because of their name or type" -- this leads me to believe that perhaps this is a wider Windows/MS problem? Somehow, I doubt this is the issue.
Just to double check, I tried all of my aforementioned steps in Git Bash (my preferred terminal on Windows), CMD, and Powershell -- all exhibited the same behaviour.
Thanks in advance.
Ah, well... I feel silly now. Same issue as with Rollup — I had to install it with npm globally. But, I missed that there's both sirv and sirv-cli on NPM.
Running npm install -g sirv-cli fixed my issue.
However... I would still like to know why I don't see this issue mentioned anywhere in any guide anywhere else with all the rest of Svelte's Hello World stuff. Any information would be greatly appreciated!

ETIMEDOUT Error while installing Node packages on Windows

I am trying to install node packages on my windows machine using npm from a fresh install of node.
however, I am getting ETIMEDOUT errors. I checked few other stackoverflow questions with similar problem and almost all of them are related to problems when behind a proxy. Same is not the case with me. My system is not behind any proxy server. Can someone help me with resolving it.
PS C:\windows\system32> npm -v
2.5.1
PS C:\windows\system32> npm install bower -g
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i
nstall" "bower" "-g"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! syscall connect
npm ERR! network connect ETIMEDOUT
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! Please include the following file with any support request:
npm ERR! C:\windows\system32\npm-debug.log
I am posting this answer in case some one faces the same issue.
I was able to solve this by running following command:
npm config delete proxy
First, run
npm config list
and check whether you are behind a proxy. If so, try running
npm config delete proxy
npm config delete http-proxy
npm config delete https-proxy
as required
**If this method did not work, reinstall nodejs.
I tried all the suggested solutions I could find on GitHub forums and StackOverflow topics. Finally disabling my router's firewall solved the issue immediately.
I am using Windows 10, node 4.0.0 and npm 2.13.4.
First see the npm config list:
npm config list
If you don't find http-proxy, https-proxy and proxy correctly set, then
You need to configure npm to work with your web proxy. For example:
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
npm config set http-proxy http://proxy.company.com:8080
Not on Windows but it can help there as well.
Node 16 worked, Node 18 did not. Turns out it was related to IPv6. As soon as I disabled IPv6 the connection did not timeout any more. The target registry was a Nexus server.
You can try to throttle the number of simultaneous connections with the following command (for example 3 maximum simultaneous connections):
npm set maxsockets 3
The CLI has been allowing this option since npm#3.8.0. The default is 50 simultaneous connections max. See this link for further reference.
If removing the npm proxy config settings (or correctly setting them, if that is necessary for you) did not fix it, then This github issue discusses what might be happening. My summary is that for some reason the ipv6 dns resolution to the registry is not resolving correctly and seems to be randomly failing for people.
My command was fetching from registry.npmjs.org using npm 9.1.2 and node 18.12.1 - I was running this from a windows terminal via vscode.
I ended up disabling ipv6 via the network properties of my adapter see here
Again, changing the npm config proxy settings did not resolve anything for me. I re-enabled ipv6 after my command finished.
For people working in corporates (where you cannot delete or edit the proxy configuration of the organization):
There must be an .npmrc file in your users folder. If not, you can create one. This file can be edited to register the proxy settings of your organization. Contact your organization's IT team to get the relevant proxy details.
Example of the .npmrcfile contents for my organization:
strict-ssl=false
registry=https://nexus.com/nexus/content/groups/npm-read/
proxy=http://primary-proxy.gslb.intranet.com:8080/
https-proxy=http://primary-proxy.gslb.intranet.com:8080
This file can be found in your users folder:
I was not able to install any packages before because of this error then after 1 hour, I finally resolved it because I was not behind a proxy but the proxy parameters got set in the npm config thats why that error was showing.
I'am posting it because if anyone is facing the same issue and if they are not behind any proxy then they can use the following commands:-
npm config rm proxy
npm config rm https-proxy
npm config delete http-proxy
npm config delete https-proxy
set HTTP_PROXY=null
set HTTPS_PROXY=null
One way to resolve this is to set Fiddler as your proxy server. This probably only works for windows.
Running Fiddler, type these commands:
npm config set proxy http://localhost:8888
npm config set https-proxy http://localhost:8888
Before you do this, Rules -> Automatically Authenticate
I solved with:
npm config set proxy null
I solved it with the following:
npm config rm proxy
npm config rm https-proxy
npm config delete http-proxy
npm config delete https-proxy
set HTTP_PROXY=null
set HTTPS_PROXY=null
I was going through the same error. the root cause was the proxy settings : there are several answers provided in here to reset the proxy but none of them worked for me.
Below commands solved my problem, give them a try.
npm config rm proxy
npm config rm https-proxy
If none of the mention solutions works for you then, try switching your node version.
I tried to implement all solutions and suggested commands for npm and yarn but it's not resolved.
When I disable my VPN and try to "yarn install, " it will work fine.
After all the effort with no result, I reboot my router and it works!
On windows 10, adding Node.js to the firewall authorized applications AND restarting the laptop solved the problem.
I also face this issue
Solution
Just uninstall Node.js .
uninstall its package also which you downloaded from website.
Download Node.js from website.
Reinstall Node.js .
It will Work.

What permissions do I need to install Bower on Vagrant on Windows?

I kept running into this error when installing Bower through NPM on a Windows 7 machine running a precise32 Ubuntu Box on Vagrant. I tried every combination of commands and always got the same or very similar errors
Installing locally, globally, with sudo, without sudo, etc.
...
npm ERR! Error: EPERM, open '/home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js'
npm ERR! { [Error: EPERM, open '/home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js']
npm ERR! errno: 50,
npm ERR! code: 'EPERM',
npm ERR! path: '/home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.2.0-23-generic-pae
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "bower" "--no-bin-links"
npm ERR! cwd /home/vagrant
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! path /home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, open '/home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js'
...
EDIT: As well as my answer below please note the file directory + file size limitation when using Windows (260 characters I believe)
I have had to install vagrant in a folder directly on my c:/ drive to get over this limitation as some packages end up having nested dependencies causing this limit to be exceeded. My problem was with grunt-contrib-less
Self answering as I couldn't find a solution anywhere else on StackOverflow
I eventually got it to work via changing to the root user via su root and trying to install globally again. Apparently just using sudo wasn't enough.
So it became
root#precise32: npm install -g bower --no-bin-links
EDIT: As well as this solution please note the file directory + file size limitation when using Windows (260 characters I believe)
I have had to init a vagrant instance in a folder directly on my c:/ drive to get over this limitation as some packages end up having nested dependencies causing this limit to be exceeded. My problem was with grunt-contrib-less
EDIT 2: After coming across this problem again and again I'll add a bit more information for people here regarding node modules and vagrant under Windows.
I now overcome the file path limitation via putting any long dependency chains that fail due to path length (usually EPERM) I add one of the packages in the chain to my own package.json. This means the long requirement chain is split as npm does not re-install the package deeper in the tree if it's already installed.
Just make sure you require a version which is valid for the version string for the module.
The order of the dependencies in package.json does not matter, dependencies are resolved before anything is installed
One of ops guys (vagrant and node.js quick tip) found a solution for that problem. Basically you need to have the following code in your Vagrant file:
config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
That will allow npm to create symlinks for the modules that require it.
Than install packages without forcing the symlinks. So, when running npm install on a virtual machine created through vagrant, run it as:
sudo npm install --no-bin-link
It was usefull for me when I installed the express
module.
With Vagrant 1.5 on Windows, you can now use rsync or smb folder shares which won't have this problem.
To get around the 260 character file length limit in windows, which npm seems to surpass quite easily, you can use the npm link command.
This will allow you to use node_modules local to your project. If you run it on your guest machine it will install them globally on your guest machine and then create a symlink in your projects node_modules folder. That way only the symlink is shared to the windows host machine and the 260 file length limit is not exceeded.
I go over this in more detail in this blog post here.

NPM Install fails inconsitently

I'm trying to install some modules using NPM on Cygwin (Windows 7), but the install is going incredibly inconsistently. Some packages fail repeatedly on install, but some succeed; moreover, the same package can fail several times and then succeed with no change in the system. Installing the markdown package failed three times in a row, and then succeeded. The failures were:
npm ERR! couldn't unpack /tmp/npm-1310104605595/1310104605596-0.844648783095181/
tmp.tgz to /tmp/npm-1310104605595/1310104605596-0.844648783095181/contents
npm ERR! Error: EACCES, Permission denied '/tmp/npm-1310104605595/1310104605596-
0.844648783095181/contents/___package.npm/package'
npm ERR!
npm ERR! Please use 'sudo' or log in as root to run this command.
npm ERR!
npm ERR! sudo npm "install" "markdown"
npm ERR!
npm ERR! or set the 'unsafe-perm' config var to true.
npm ERR!
npm ERR! npm config set unsafe-perm true
npm ERR!
npm ERR! System CYGWIN_NT-6.1-WOW64 1.7.9(0.237/5/3)
npm ERR! command "node" "/usr/local/bin/npm" "install" "markdown"
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/Paul/node_modules/express/node_modules/connect/npm-debug.log
npm not ok
Has anyone experienced this, and if so, what was the solution? And yes, I've set the unsafe-perm config variable, and it doesn't seem to change anything... Also, this is not limited to just this package; pretty much anything I try to install seems to have this issue.
P.S: I don't know if you filled an issue at Github yet because Isaacs prefers that to Stackoverflow.com. At github he will receive an email when somebody fills an issue and has excellent respond-times. But after a quick search it seems you allready filled an issue..
Windows Support
I'm trying to install some modules
using NPM on Cygwin (Windows 7), but
the install is going incredibly
inconsistently.
NPM does NOT support Windows. Isaacs does not fix(allocate resources) to any bugs under Windows(Cygwin how does allocate some time to, but not that much) Operating System. He does fix bugs under Cygwin, but you are better of installing a POSIX OS.
Caveat 2: Sorry, Windows!
Any bugs about this not working on a
native Windows system (ie, not Cygwin)
will most likely be closed with
wontfix.
If you ask me you are probably better of(Below I point to the WIKI page to install NPM on Cygwin) installing Ubuntu(Unix) using dual-boot and do your (web)development on Unix. When you get the hang of it you probably will never switch back to Windows again.
Installing under Cygwin
Also there is a page explaining how to install NPM.
Important: Make sure you follow ALL
the steps! It’ll seem like it’s
working before you get to the end. But
it is a dirty, lying liar. Don’t
believe it. Do the steps all the way
to the end. If you don’t, you’re going
to complain that npm says
“ECONNREFUSED” and then post a bug,
and I’ll ask if you did all the steps,
and you’ll feel silly.
Did you follow these steps on their WIKI page to install NPM on Windows=> https://github.com/joyent/node/wiki/Building-node.js-on-Cygwin-(Windows)

Resources