Vue press 2 deploy to netlify failed with error - netlify

I was learning vuepress and tried make a small blog site and decided to deploy it on netlify and it gave me this error. After some googling I found that removing package-lock.json would help but I am facing the same error after deleting package-lock.json
5:57:41 PM: npm ERR! code EBADPLATFORM
5:57:41 PM: npm ERR! notsup Unsupported platform for esbuild-windows-64#0.14.36: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})
5:57:41 PM: npm ERR! notsup Valid OS: win32
5:57:41 PM: npm ERR! notsup Valid Arch: x64
5:57:41 PM: Creating deploy upload records
5:57:41 PM: npm ERR! notsup Actual OS: linux
I am using Vite as package manager.It is running fine in local server.

TL;DR;
Try running npm update to update the esbuild package dependencies in your package-lock.json file.
Background
First, you should not remove your package-lock.json file. It is an important file with a purpose and should remain version controlled (https://nodejs.dev/learn/the-package-lock-json-file).
I believe the issue is that vite uses esbuild. esbuild lists a number of optionalDependencies:
"optionalDependencies": {
"esbuild-android-64": "0.14.32",
"esbuild-android-arm64": "0.14.32",
"esbuild-darwin-64": "0.14.32",
"esbuild-darwin-arm64": "0.14.32",
"esbuild-freebsd-64": "0.14.32",
// and so on...
}
Each of these dependencies lists a CPU and OS it depends on, like in your error:
"node_modules/esbuild-windows-64": {
"version": "0.14.32",
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.32.tgz",
"integrity": "sha512-+p4MuRZekVChAeueT1Y9LGkxrT5x7YYJxYE8ZOTcEfeUUN43vktSn6hUNsvxzzATrSgq5QqRdllkVBxWZg7KqQ==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
}
For some reason, up to a certain version of esbuild these dependencies cause Netlify to think these platforms are required and thus it fails because its container is running Linux. Updating to at least version 0.14.36 fixed the problem for me, there's an ever newer version out than that at the time of this writing. You will still see warnings such as
2:59:00 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: esbuild-windows-64#0.14.49 (node_modules/esbuild-windows-64):
2:59:00 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-windows-64#0.14.49: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})
but the build will no longer fail.

Related

How to solve deploy error with node to heroku (code EBADPLATFORM)

I am having issues deploying my node app to Heroku. I am getting the following error in the logs:
Installing dependencies
Installing node modules
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents#2.3.2: wanted {"os":"darwin"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS: darwin
npm ERR! notsup Valid Arch: undefined
npm ERR! notsup Actual OS: linux
npm ERR! notsup Actual Arch: x64
I already deleted the node_modules folder and did npm install. I checked the package-lock-json file for the version. Example.
"node_modules/#next/swc-darwin-x64": {
"version": "11.1.4",
"resolved": "https://registry.npmjs.org/#next/swc-darwin-x64/-/swc-darwin-x64-11.1.4.tgz",
"integrity": "sha512-5i9tOQNO8kawwggHvQUVR3a5KzIGaE2dw1g1kL//z/N840djvGseHrJSFEGdP1c35gM+dSGPpAKHmeBKrwHM8g==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
There are some specified with darwin but not sure what I would need to add here. Any help would be greatly appreciated. Thanks!

Why does my Angular project pipeline keep failing?

I have a angular project that I'm trying to tag and push to dev server using git and gitlab.
After my 4th unsuccessful try, I'm now at a loss to what I'm doing wrong.
This is my job log:
[0KRunning with gitlab-runner 12.9.0 (4c96e5ad)
[0;m[0K on dev-runner yMELGGtz
[0;msection_start:1608540813:prepare_executor
[0K[0K[36;1mPreparing the "shell" executor[0;m
[0;m[0KUsing Shell executor...
[0;msection_end:1608540813:prepare_executor
[0Ksection_start:1608540813:prepare_script
[0K[0K[36;1mPreparing environment[0;m
[0;mRunning on WIN-AVAH5M2LJ5E...
section_end:1608540814:prepare_script
[0Ksection_start:1608540814:get_sources
[0K[0K[36;1mGetting source from Git repository[0;m
[0;m[32;1mFetching changes with git depth set to 50...[0;m
Reinitialized existing Git repository in C:/runner/builds/yMELGGtz/0/gitlab_username/project_name-auth-front/.git/
From https://gitlab.com/gitlab_username/project_name-auth-front
* [new ref] refs/pipelines/232677922 -> refs/pipelines/232677922
* [new tag] v20201221.3 -> v20201221.3
[32;1mChecking out 2e8cffbc as v20201221.3...[0;m
Removing node_modules/
git-lfs/2.10.0 (GitHub; windows amd64; go 1.12.7; git a526ba6b)
[32;1mSkipping Git submodules setup[0;m
section_end:1608540861:get_sources
[0Ksection_start:1608540861:restore_cache
[0K[0K[36;1mRestoring cache[0;m
[0;msection_end:1608540862:restore_cache
[0Ksection_start:1608540862:download_artifacts
[0K[0K[36;1mDownloading artifacts[0;m
[0;msection_end:1608540863:download_artifacts
[0Ksection_start:1608540863:build_script
[0K[0K[36;1mRunning before_script and script[0;m
[0;m[32;1m$ npm i[0;m
npm WARN deprecated ini#1.3.5: Please update to ini >=1.3.6 to avoid a prototype pollution issue
> core-js#3.6.5 postinstall C:\runner\builds\yMELGGtz\0\gitlab_username\project_name-auth-front\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"
> #angular/cli#11.0.4 postinstall C:\runner\builds\yMELGGtz\0\gitlab_username\project_name-auth-front\node_modules\#angular\cli
> node ./bin/postinstall/script.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules\watchpack-chokidar2\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.1.3 (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"})
added 1650 packages from 1206 contributors and audited 1654 packages in 113.077s
79 packages are looking for funding
run `npm fund` for details
found 3 low severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
[32;1m$ npm run build-dev[0;m
> project_name-auth#0.0.0 build-dev C:\runner\builds\yMELGGtz\0\gitlab_username\project_name-auth-front
> ng build --hmr --base-href /auth/ --deploy-url /auth/
Unknown option: '--hmr'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project_name-auth#0.0.0 build-dev: `ng build --hmr --base-href /auth/ --deploy-url /auth/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project_name-auth#0.0.0 build-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:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_logs\2020-12-21T08_56_23_982Z-debug.log
section_end:1608540984:build_script
[0Ksection_start:1608540984:upload_artifacts_on_failure
[0K[0K[36;1mUploading artifacts for failed job[0;m
[0;msection_end:1608540985:upload_artifacts_on_failure
[0K[31;1mERROR: Job failed: exit status 1
[0;m
Please note that my OS is Ubuntu 20.04 and I have replaced gitlab username and project name in the log with gitlab_username and project_name. (because it's not my project or my repository)
Expanding what #MikeOne wrote in the comment and as stated in webpack Hot Module Replacement documentation,
HMR is not intended for use in production, meaning it should only be
used in development.
Previously, in my package.json I had:
"scripts": {
"build": "ng build --prod --hmr --base-href /auth/ --deploy-url /auth/",
"build-dev": "ng build --hmr --base-href /auth/ --deploy-url /auth/"
},
So, I just changed it to:
"scripts": {
"build": "ng build --prod --base-href /auth/ --deploy-url /auth/",
"build-dev": "ng build --base-href /auth/ --deploy-url /auth/"
},
And it worked!

Sharp installs via npm on Windows 10 x64, but gatsby develop does not find procedure \sharp.node

I have installed the windows-build-tools and node-gyp. Installing the gatsby-plugin-sharp did work:
+ sharp#0.23.0
+ gatsby-plugin-sharp#2.2.22
+ gatsby-transformer-sharp#2.2.14
added 255 packages from 219 contributors, removed 4 packages, updated 6 packages and audited 31172 packages in 77.277s
found 0 vulnerabilities
I had only 2 warnings:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
But if I start gatsby develop, I get an error:
PS D:\Projekte\gatsby\projectname> gatsby develop
success open and validate gatsby-configs - 0.260 s
Something went wrong installing the "sharp" module
Die angegebene Prozedur wurde nicht gefunden.
\\?\D:\Projekte\gatsby\projectname\node_modules\gatsby-plugin-manifest\node_modules\sharp\build\Release\sharp.node
- Remove the "node_modules/sharp" directory, run "npm install" and look for errors
- Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/
- Search for this error at https://github.com/lovell/sharp/issues
I did remove the folder and made "npm install", but this does not work. The file sharp.node is there, but what does "\\?\" mean?
I reinstalled the gatsby-plugin-sharp and gatsby-plugin-manifest and gatsby-image and made npm install with an empty cache. This worked. There are args now in the package.json of the sharp module:
"_args": [
[
"sharp#0.23.0",
"D:\\Projekte\\gatsby\\projectname"
]
],
Seams that something got broken by installing sharp (not necessary) after the gatsby-plugin-sharp.

npm install lite-server --save-dev error

I'm trying to use node for the first time in a VS project in windows. I installed node.js, below is the info:
node -v
v8.9.3
npm -v
5.5.1
Completed setup in the project using npm init, that seemed to work fine.
npm install lite-server --save-dev produced the following error:
$ npm install lite-server --save-dev
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents#1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS: darwin
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: win32
npm ERR! notsup Actual Arch: x64
I don't understand the errors. Help. Thanks!
The error comes from fsevents#1.1.3, which is a dependency package of lite-server.
fsevents#1.1.3 only works in macOS. See its npm info page.
Native access to OS X FSEvents in Node.js
The FSEvents API in OS X allows applications to register for
notifications of changes to a given directory tree. It is a very fast
and lightweight alternative to kqueue.
Similar issues also apply to other npm packages with such dependency.
I am using npm#5.6.0, the latest stable release, and tried install on my Windows. The error turns out to a warning and let lite-server installed eventually. Anyway, fsevents is just an optional dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.1.3 (node_modules\lite-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ lite-server#2.3.0
added 279 packages in 81.466s
I found the fix for Ubuntu 18.04/20.04 after working for whole day. This should work for other Linux distros
Run following command for globally using lite-server
sudo npm install lite-server -g
Your package.json file should contain
"devDependencies": {
"lite-server": "^2.5.4"
}
and scipt should look like
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server"
},
For development mode run following
sudo npm i lite-server --save-dev
Local server could started using npm command
npm start

Force npm install to install optional dependencies for other platforms

I'm building a build task for Visual Studio Team Services. In this task I'm using 7zip-bin to package the binary for 7zip for linux, mac and windows.
This is all nice and it would work if I had the ability to deploy just the package.json to the build server, but no... A build task contains all its dependencies at build time.
Is there a way I can force npm to download all OS optional packages somehow? Or will I have to download the file myself during build and extract it?
Right now I'm using
npm install 7zip-bin --save
Which results in:
C:\temp>npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: 7zip-bin-linux#^1.0.3 (node_modules\7zip-bin\node_modules\7zip-bin-linux):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 7zip-bin-linux#1.0.3: wanted {"os":"linux","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: 7zip-bin-mac#^1.0.1 (node_modules\7zip-bin\node_modules\7zip-bin-mac):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 7zip-bin-mac#1.0.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
installing each optional package directly isn't possible, when I run
npm install 7zip-bin-linux --save
on a windows machine, the install is skipped and I get a EBADPLATFORM error.
I understand I can't run these on my machine, but I need to package them in a vsix file (a glorified zip) so I can use them when my build task is running on these other platforms.
You should depend on these 3 optional packages, because you never know if 7zip-bin will change it's optional dependencies, which you are using directly.
For example:
dependencies: {
"7zip-bin-mac": "^1.0.1",
"7zip-bin-win": "^2.0.2",
"7zip-bin-linux": "^1.0.3"
}
Using either way, you need to run npm install -f to force the installation.

Resources