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

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!

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/",
}

vue awesome swiper install failed on windows

I'm trying to install vue-awesome-swiper with npm using this command
npm i vue-awesome-swiper --save
I'm getting this error
npm ERR! Line breaks can't be quoted on Windows
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USERNAME\AppData\Local\npm-cache\_logs\2021-04-06T18_35_21_789Z-debug.log
I opened the log and I figured that the problem is caused by this line here
80 info run swiper#5.4.5 postinstall node_modules/swiper echo "[35m[1mLove Swiper? Support Vladimir's work by donating or pledging on patreon:[22m[39m
80 info run > [32mhttps://patreon.com/vladimirkharlampidi[0m
80 info run "
As you can see from the log here it's triggering postinstall script and it's just trying to print a message to support the package author.
To fix this issue you can simply install the package without running any scripts with the --ignore-scripts flag like this:
npm i vue-awesome-swiper --save --ignore-scripts

What is the best way to precompile EmberJS templates on Windows

I'm trying to determine the best way to precompile EmberJS templates using Windows and can't seem to find any good options.
Can anyone recommend a good proven solution?
I'm using Ember v 1.10.0
EDIT:
I have installed the latest version of NodeJS and followed the instructions from here: http://www.ember-cli.com/#getting-started.
For the record, I am using Windows 8.1 running on a Surface Pro 2.
I have tried installing Ember CLI using NodeJs and I get the following error(s):
C:\>npm install -g ember-cli
npm WARN engine makeerror#1.0.10: wanted: {"node":"0.6.x"} (current: {"node":"0.
12.0","npm":"2.5.1"})
npm WARN engine tmpl#1.0.3: wanted: {"node":"0.6.x"} (current: {"node":"0.12.0",
"npm":"2.5.1"})
C:\Users\me\AppData\Roaming\npm\ember -> C:\Users\me\AppData\Roaming\npm
\node_modules\ember-cli\bin\ember
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" "install" "-g" "ember-cli"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code EPEERINVALID
npm ERR! peerinvalid The package handlebars does not satisfy its siblings' peerD
ependencies requirements!
npm ERR! peerinvalid Peer ember-template-compiler#1.8.0 wants handlebars#~1
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" "install" "-g" "ember-cli"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! Uncaught, unspecified "error" event.
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! C:\npm-debug.log
It depends what tools/frameworks you are using:
If you are using Ember CLI (and I'd strongly recommend it), it is able to precompile your templates directly from the command line (and much more). It's a bit slower on Windows that Unix systems (due to symlink issues on Windows) but the Ember team is working on it. I personally use Ember CLI both on Windows and Linux Debian for my own projects and it works great.
If you do not want to use Ember CLI for now and work with .Net you can use csharp-ember-handlebars within an ASP.Net MVC project. Note that in this case, the precompilation of your templates will happen when the server is started via the ASP.Net MVC bundling mechanism.
If you just want to compile templates outside of any framework then you could install Node.js and use the node-ember-precompile package. This is probably the most tedious way but could be automated using Grunt or Gulp.
In general, no matter what you use on the server (Node, Rails, Python, .Net, Java, ...) you will always find a server-side library to handle your templates precompilation.
I would still recommend working with Ember CLI if possible (since this is the future of Ember, and not only for the build), then deploy your precompiled templates directly behind IIS, Apache or (even better) Nginx.
Let me know if you need more details for a specific environment.

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