Home
Support Forums

Vite build error

My site name is: corecontrols-cloud-coreapp

I am trying to build and deploy my SPA using vite using github.
When building locally on my machine, I have no issues. I can also publish the site from my machine without having any problems. However, when github triggers the build of the SPA on netlify it fails with the following error:

Blockquote
3:28:19 PM: Build ready to start
3:28:21 PM: build-image version: c6001ed68662a13e5deb24abec2b46058c58248a
3:28:21 PM: build-image tag: v3.9.0
3:28:21 PM: buildbot version: 1ed4041128c7c024b4c4b72e2ad30a0740c570a7
3:28:21 PM: Fetching cached dependencies
3:28:21 PM: Starting to download cache of 131.4MB
3:28:23 PM: Finished downloading cache in 2.221130838s
3:28:23 PM: Starting to extract cache
3:28:28 PM: Finished extracting cache in 4.665259258s
3:28:28 PM: Finished fetching cache in 6.939117058s
3:28:28 PM: Starting to prepare the repo for build
3:28:29 PM: Preparing Git Reference refs/heads/main
3:28:30 PM: Parsing package.json dependencies
3:28:30 PM: Starting build script
3:28:30 PM: Installing dependencies
3:28:30 PM: Python version set to 2.7
3:28:31 PM: Started restoring cached node version
3:28:33 PM: Finished restoring cached node version
3:28:34 PM: v12.18.0 is already installed.
3:28:35 PM: Now using node v12.18.0 (npm v6.14.4)
3:28:35 PM: Started restoring cached build plugins
3:28:35 PM: Finished restoring cached build plugins
3:28:35 PM: Attempting ruby version 2.7.2, read from environment
3:28:36 PM: Using ruby version 2.7.2
3:28:36 PM: Using PHP version 5.6
3:28:36 PM: Started restoring cached node modules
3:28:36 PM: Finished restoring cached node modules
3:28:37 PM: Installing NPM modules using NPM version 6.14.4
3:28:43 PM: npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I’ll try to do my best with it!
3:28:43 PM: > yorkie@2.0.0 uninstall /opt/build/repo/node_modules/yorkie
3:28:43 PM: > node bin/uninstall.js
3:28:43 PM: husky
3:28:43 PM: uninstalling Git hooks
3:28:43 PM: done
3:28:48 PM: > esbuild@0.12.24 postinstall /opt/build/repo/node_modules/esbuild
3:28:48 PM: > node install.js
3:28:50 PM: npm WARN bootstrap@5.1.0 requires a peer of @popperjs/core@^2.9.3 but none is installed. You must install peer dependencies yourself.
3:28:50 PM: npm WARN null-loader@3.0.0 requires a peer of webpack@^4.3.0 but none is installed. You must install peer dependencies yourself.
3:28:50 PM: npm WARN sass-loader@10.2.0 requires a peer of webpack@^4.36.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
3:28:50 PM: npm WARN corecontrols.cloud@0.0.0 No repository field.
3:28:50 PM: npm WARN corecontrols.cloud@0.0.0 No license field.
3:28:50 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
3:28:50 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
3:28:50 PM: added 10 packages from 9 contributors, removed 1395 packages, updated 31 packages and audited 126 packages in 12.091s
3:28:50 PM: 11 packages are looking for funding
3:28:50 PM: run npm fund for details
3:28:50 PM: found 0 vulnerabilities
3:28:50 PM: NPM modules installed
3:28:50 PM: Started restoring cached go cache
3:28:50 PM: Finished restoring cached go cache
3:28:50 PM: go version go1.14.4 linux/amd64
3:28:50 PM: go version go1.14.4 linux/amd64
3:28:50 PM: Installing missing commands
3:28:50 PM: Verify run directory
3:28:51 PM: ​
3:28:51 PM: ────────────────────────────────────────────────────────────────
3:28:51 PM: Netlify Build
3:28:51 PM: ────────────────────────────────────────────────────────────────
3:28:51 PM: ​
3:28:51 PM: ❯ Version
3:28:51 PM: @netlify/build 18.7.3
3:28:51 PM: ​
3:28:51 PM: ❯ Flags
3:28:51 PM: baseRelDir: true
3:28:51 PM: buildId: 613060f30493310007218a93
3:28:51 PM: deployId: 613060f30493310007218a95
3:28:51 PM: ​
3:28:51 PM: ❯ Current directory
3:28:51 PM: /opt/build/repo
3:28:51 PM: ​
3:28:51 PM: ❯ Config file
3:28:51 PM: /opt/build/repo/netlify.toml
3:28:51 PM: ​
3:28:51 PM: ❯ Context
3:28:51 PM: production
3:28:51 PM: ​
3:28:51 PM: ────────────────────────────────────────────────────────────────
3:28:51 PM: 1. build.command from netlify.toml
3:28:51 PM: ────────────────────────────────────────────────────────────────
3:28:51 PM: ​
3:28:51 PM: $ vite build
3:28:52 PM: failed to load config from /opt/build/repo/vite.config.js
3:28:52 PM: error during build:
3:28:52 PM: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./dist/json/importMap.json’ is not defined by “exports” in /opt/build/repo/node_modules/vuetify/package.json
3:28:52 PM: at applyExports (internal/modules/cjs/loader.js:491:9)
3:28:52 PM: at resolveExports (internal/modules/cjs/loader.js:507:23)
3:28:52 PM: at Function.Module._findPath (internal/modules/cjs/loader.js:635:31)
3:28:52 PM: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:953:27)
3:28:52 PM: at Function.Module._load (internal/modules/cjs/loader.js:842:27)
3:28:52 PM: at Module.require (internal/modules/cjs/loader.js:1026:19)
3:28:52 PM: at require (internal/modules/cjs/helpers.js:72:18)
3:28:52 PM: at Object. (/opt/build/repo/node_modules/@vuetify/loader-shared/dist/imports/getImports.js:8:42)
3:28:52 PM: at Module._compile (internal/modules/cjs/loader.js:1138:30)
3:28:52 PM: at Module._extensions…js (internal/modules/cjs/loader.js:1158:10)
3:28:52 PM: ​
3:28:52 PM: ────────────────────────────────────────────────────────────────
3:28:52 PM: “build.command” failed
3:28:52 PM: ────────────────────────────────────────────────────────────────
3:28:52 PM: ​
3:28:52 PM: Error message
3:28:52 PM: Command failed with exit code 1: vite build
3:28:52 PM: ​
3:28:52 PM: Error location
3:28:52 PM: In build.command from netlify.toml:
3:28:52 PM: vite build
3:28:52 PM: ​
3:28:52 PM: Resolved config
3:28:52 PM: build:
3:28:52 PM: command: vite build
3:28:52 PM: commandOrigin: config
3:28:52 PM: environment:
3:28:52 PM: - NODE_ENV
3:28:52 PM: processing:
3:28:52 PM: skip_processing: true
3:28:52 PM: publish: /opt/build/repo/dist
3:28:52 PM: publishOrigin: config
3:28:52 PM: functionsDirectory: /opt/build/repo/netlify/functions
3:28:52 PM: headers:
3:28:52 PM: - for: /* values: Access-Control-Allow-Origin: '’ headersOrigin: config redirects: - from: / status: 200 to: /index.html redirectsOrigin: configCaching artifacts
3:28:52 PM: Started saving node modules
3:28:52 PM: Finished saving node modules
3:28:52 PM: Started saving build plugins
3:28:52 PM: Finished saving build plugins
3:28:52 PM: Started saving pip cache
3:28:53 PM: Finished saving pip cache
3:28:53 PM: Started saving emacs cask dependencies
3:28:53 PM: Finished saving emacs cask dependencies
3:28:53 PM: Started saving maven dependencies
3:28:53 PM: Finished saving maven dependencies
3:28:53 PM: Started saving boot dependencies
3:28:53 PM: Finished saving boot dependencies
3:28:53 PM: Started saving rust rustup cache
3:28:53 PM: Finished saving rust rustup cache
3:28:53 PM: Started saving go dependencies
3:28:53 PM: Finished saving go dependencies
3:28:53 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:28:53 PM: Creating deploy upload records
3:28:53 PM: Failing build: Failed to build site
3:28:53 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
3:28:53 PM: Finished processing build request in 31.659421718s
Blockquote

To try to debug I downloaded the netlify/build container and repository to run locally the build, however, to my surprise, it was able to build successfully locally on the container.

Blockquote
~/build-image$ ./test-tools/test-build.sh /home/alanm/corecontrols.cloud ‘vite build’
Using temp cache dir: tmp/tmp.ZVZWgcJbrs/cache
Cloning into ‘/opt/buildhome/repo’…
done.
Installing dependencies
Python version set to 3.8
Downloading and installing node v16.8.0…
Downloading https://nodejs.org/dist/v16.8.0/node-v16.8.0-linux-x64.tar.xz
Computing checksum with sha256sum
Checksums matched!
Now using node v16.8.0 (npm v7.21.0)
Started restoring cached build plugins
Finished restoring cached build plugins
Attempting ruby version 2.7.2, read from environment
Using ruby version 2.7.2
Using PHP version 8.0
Started restoring cached node modules
Finished restoring cached node modules
Installing NPM modules using NPM version 7.21.0
npm WARN deprecated urix@0.1.0: Please see GitHub - lydell/urix: [DEPRECATED] Makes Windows-style paths more unix and URI friendly.
npm WARN deprecated resolve-url@0.2.1: GitHub - lydell/resolve-url: [DEPRECATED] Like Node.js’ `path.resolve`/`url.resolve` for the bro
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.

added 454 packages, and audited 455 packages in 12s

17 packages are looking for funding
run npm fund for details

5 moderate severity vulnerabilities

To address all issues, run:
npm audit fix

Run npm audit for details.
NPM modules installed
Started restoring cached go cache
Finished restoring cached go cache
go version go1.16.5 linux/amd64
go version go1.16.5 linux/amd64
Installing missing commands
Verify run directory
Executing user command: vite build
vite v2.5.3 building for production…
✓ 547 modules transformed.
warnings when minifying css:

:113:0: warning: “@charset” must be the first rule in the file
113 │ @charset “UTF-8”;
╵ ~~~~~~~~
:109:0: note: This rule cannot come before a “@charset” rule
109 │ #category[data-v-6cf7918e] {
╵ ^

dist/assets/materialdesignicons-webfont.9bdfaf27.eot 1002.34 KiB
dist/assets/materialdesignicons-webfont.da7fba3c.woff2 317.62 KiB
dist/assets/materialdesignicons-webfont.8bded8f4.woff 454.29 KiB
dist/assets/materialdesignicons-webfont.c14484cf.ttf 1002.13 KiB
dist/index.html 0.55 KiB
dist/assets/index.96b09c45.css 639.30 KiB / brotli: skipped (large chunk)
dist/assets/About.2b534817.js 0.19 KiB / brotli: 0.15 KiB
dist/assets/vendor.49519a81.css 94.55 KiB / brotli: 10.86 KiB
dist/assets/index.6346f7cf.js 960.96 KiB / brotli: skipped (large chunk)
dist/assets/vendor.191f004a.js 502.21 KiB / brotli: skipped (large chunk)

(!) Some chunks are larger than 500 KiB after minification. Consider:

  • Using dynamic import() to code-split the application
  • Use build.rollupOptions.output.manualChunks to improve chunking: rollup.js
  • Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
    Caching artifacts
    Started saving node modules
    Finished saving node modules
    Started saving build plugins
    Finished saving build plugins
    Started saving pip cache
    Finished saving pip cache
    Started saving emacs cask dependencies
    Finished saving emacs cask dependencies
    Started saving maven dependencies
    Finished saving maven dependencies
    Started saving boot dependencies
    Finished saving boot dependencies
    Started saving rust rustup cache
    Finished saving rust rustup cache
    Started saving go dependencies
    Finished saving go dependencies

Blockquote

I tried to google about the problem but got no luck.
Thank you in advance for any help.

It appears to be a problem with one of the modules. Would sharing your repo be possible?

Yeah. I understand probably an error in the module, however, interesting the error does not happen when building inside netlify container locally, I was expecting the building environment would be similar.

I can’t share the repo but I can share my package.json

{
“name”: “----”,
“version”: “0.0.0”,
“scripts”: {
“serve”: “vite serve --port 8888 -d”,
“build”: “vite build”,
“dev”: “vite”
},
“dependencies”: {
“azure/msal-browser”: “^2.16.1”,
“axios”: “^0.21.1”,
“bootstrap”: “^5.1.0”,
“roboto-fontface”: “*”,
“vue”: “^3.2.6”,
“vue-router”: “^4.0.11”,
“vuetify”: “^3.0.0-alpha.0”,
“vuex”: “^4.0.2”
},
“devDependencies”: {
“mdi/font”: “^5.9.55”,
“vitejs/plugin-vue”: “^1.6.0”,
“vue/compiler-sfc”: “^3.2.6”,
“vuetify/vite-plugin”: “^1.0.0-alpha.2”,
“lodash”: “^4.17.21”,
“sass”: “~1.32.0”,
“sass-loader”: “^10.0.0”,
“vite”: “^2.5.2”,
“vue-cli-plugin-vuetify”: “~2.4.2”
}
}

On the following lines there is a @ however I had to remove to be able to post it here :frowning:

 "azure/msal-browser": "^2.16.1",
 "mdi/font": "^5.9.55",
 "vitejs/plugin-vue": "^1.6.0",
 "vue/compiler-sfc": "^3.2.6",
 "vuetify/vite-plugin": "^1.0.0-alpha.2",

Hi,

I removed the package from the project and now it is working and building on netlify site.
Would someone knows why I was not getting the same error when building locally using the netlify/build container with the test-tools/test-build.sh?

Thank you

That’s a difficult question - not something I can test or comment on without being able to see it happen myself.

But it’s great you could get it working.