2

I tried to install laravel9/vite app on Ubuntu 18.04 on my remote host and got error:

root@nsn-do-lamp:/var/www/html/mng-products# npm -v
6.14.8
root@nsn-do-lamp:/var/www/html/mng-products# npm run  build

> @ build /var/www/html/mng-products > vite build

failed to load config from /var/www/html/mng-products/vite.config.js error during build: Error: Cannot find module 'node:path' Require stack:

  • /var/www/html/mng-products/node_modules/vite/dist/node-cjs/publicUtils.cjs
  • /var/www/html/mng-products/node_modules/vite/index.cjs
  • /var/www/html/mng-products/vite.config.js
  • /var/www/html/mng-products/node_modules/vite/dist/node/chunks/dep-74663fff.js

at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725:27) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at Object.<anonymous> (/var/www/html/mng-products/node_modules/vite/dist/node-cjs/publicUtils.cjs:5:14) at Module._compile (internal/modules/cjs/loader.js:1063:30) at Module._extensions..js (internal/modules/cjs/loader.js:1092:10) at Object._require.extensions.<computed> [as .js] (file:///var/www/html/mng-products/node_modules/vite/dist/node/chunks/dep-74663fff.js:63058:17) at Module.load (internal/modules/cjs/loader.js:928:32) at Function.Module._load (internal/modules/cjs/loader.js:769:14) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @ build: vite build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the @ build 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!     /root/.npm/_logs/2022-09-21T11_26_59_040Z-debug.log


root@nsn-do-lamp:/var/www/html/mng-products# cat /var/www/html/mng-products/vite.config.js import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin';

    export default defineConfig({
    plugins: [
    laravel({
    input: [
    'resources/css/app.css',
    'resources/js/app.js',
    ],
    refresh: true,
    }),
    ],
    });

root@nsn-do-lamp:/var/www/html/mng-products# node -v v14.15.1

root@nsn-do-lamp:/var/www/html/mng-products# whereis node node: /usr/bin/node /usr/local/bin/node /usr/include/node /usr/share/man/man1/node.1.gz

root@nsn-do-lamp:/var/www/html/mng-products# lsb_release -d; uname -r; uname -i Description: Ubuntu 18.04.5 LTS 4.15.0-192-generic x86_64

Any ideas how it can be fixed ?

my OS :

root@nsn-do-lamp:/var/www/html/mng-products# uname -a
Linux nsn-do-lamp 4.15.0-192-generic #203-Ubuntu SMP Wed Aug 10 17:40:03 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
root@nsn-do-lamp:/var/www/html/mng-products# 
root@nsn-do-lamp:/var/www/html/mng-products# lsb_release -d; uname -r; uname -i
Description:    Ubuntu 18.04.5 LTS
4.15.0-192-generic

Thanks!

guiverc
  • 30,396
mstdmstd
  • 173
  • you probably need to do npm install first. – ob2 Sep 21 '22 at 11:50
  • Sure I run npm install firstly – mstdmstd Sep 21 '22 at 12:22
  • I added my OS info – mstdmstd Sep 21 '22 at 12:24
  • I'd also update your system if you are online; if you refer https://fridge.ubuntu.com/2021/09/17/ubuntu-18-04-6-lts-released/ you'll see when 18.04.6 was released; with installed systems upgrading a ~week before the ISO release date which is what the release signifies. Your additional details just show you're behind on security fixes & patches. – guiverc Sep 21 '22 at 12:55
  • Do you mean that I have to upgrade to ubuntu 20? – mstdmstd Sep 21 '22 at 13:17
  • Ubuntu 18.04 will upgrade to 20.04, only 18 upgrades to 20 (the year (18) and year.month (18.04) represent different Ubuntu products. You say your system is 18.04.5 which means you're a year maybe more behind on security fixes; as a 18.04 system reported itself as 18.04.6 (not 18.04.5) back in September 2021. My prior comment was suggesting you check your system is fully-upgraded (either it isn't, or* your 18.04.5 detail was incorrect*!) – guiverc Sep 21 '22 at 14:07
  • That is not from my prior expierence. Could youi please show valid steps I have to take ? – mstdmstd Sep 21 '22 at 14:10

1 Answers1

1

What does node -v give you?

I had the same error - due to an old version of node (v14.17.3) when the stable version as of now is v18.12.1

I resolved my issue by downloading the latest stable version from https://nodejs.org/en/download/

Tumelo Mapheto
  • 321
  • 3
  • 8