blogar

For this use only node v19.0.0 else you will not be able to start the app from systemd startup script 


copied the whole certification folder from url24.top/certification with .next folder

and this started working with systemd service file


To install npm, run the following command after configuring npm:

npm install npm@5.6.0


root@server:/home/cloudvariation.in/public_html# node -v

v16.18.0

root@server:/home/cloudvariation.in/public_html# npm install

npm ERR! code 1

npm ERR! path /home/cloudvariation.in/public_html/node_modules/sharp

npm ERR! command failed

npm ERR! command sh -c — (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)

npm ERR! sharp: Are you trying to install as a root or sudo user?

npm ERR! sharp: – For npm <= v6, try again with the “–unsafe-perm” flag

npm ERR! sharp: – For npm >= v8, the user must own the directory “npm install” is run in

npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies

npm ERR! sharp: Installation error: EACCES: permission denied, mkdir ‘/root/.npm’

npm ERR! A complete log of this run can be found in:

npm ERR!   /root/.npm/_logs/2022-10-18T08_07_04_058Z-debug-0.log


sudo npm install --unsafe-perm=true --allow-root


also fresh file unzipped and no file permission change works fine


got it working thanks a lot for you support

/home/cloudvariation.in/public_html/blogar

i was moving the files from blogar to outside and that was causing issue you need to execute commands from inside blogar folder only


to run on port 3001


 vi node_modules/next/dist/cli/next-start.js


edited here


to start application 


npm run start


node node_modules/next/dist/cli/next-start.js


from inside blogar folder


npm install pm2 -g


pm2 start node_modules/next/dist/cli/next-start.js







I am trying to run from inside a folder certification url24.top/certification


  1. Go to the next.config.js file and follow the instructions given in the screenshot finally save the file. The screenshot attached

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  basePath: process.env.NODE_ENV === 'production' ? process.env.NEXT_PUBLIC_BASEPATH : "",
   images: {
     loader: 'akamai',
     path: process.env.NEXT_PUBLIC_URL,
   },
}

module.exports = nextConfig

removed all commented lines

2.  .env file adds your project root folder. 

NEXT_PUBLIC_BASEPATH = /certification
NEXT_PUBLIC_URL = https://url24.top/certification/



got it working from inside a folder

1. delete everything from .next folder




 next.config.js file

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  basePath: process.env.NODE_ENV === 'production' ? process.env.NEXT_PUBLIC_BASEPATH : "",
   images: {
     loader: 'akamai',
     path: process.env.NEXT_PUBLIC_URL,
  },
}

module.exports = nextConfig



then build the project

after this comment the // module.exports = nextConfig

then npm start



to start the application automatically


vi /lib/systemd/system/blogarcert.service



[Unit]

Description=app

After=multi-user.target


[Service]

Type=idle

ExecStart=npm start

WorkingDirectory=/home/urlshortener.top/public_html/public/certification

User=root


[Install]

WantedBy=multi-user.target



sudo chmod 644 /lib/systemd/system/blogarcert.service

sudo systemctl daemon-reload
sudo systemctl enable blogarcert.service
sudo systemctl start blogarcert.service
sudo systemctl status blogarcert.service

How can the default node version be set using NVM?



nvm alias default 6.11.5 if you want it pegged to that specific version.

You can also do nvm alias default 16.

Either way, you'll want to upgrade to the latest version of nvm (v0.33.11 as of this writing)

$ nvm alias default 16.14.2
# nvm set default node.js version 16.14.2

$ node -v
# v16.14.2

root@server:/home/cloudvariation.in/public_html/blogar# nvm alias default 16.18.0

default -> 16.18.0 (-> v16.18.0)

nvm use default

root@server:/home/cloudvariation.in/public_html/blogar# nvm use default
Now using node v16.18.0 (npm v8.19.2)
root@server:/home/cloudvariation.in/public_html/blogar# node -v
v16.18.0

This will set the default to be the most current version of node

nvm alias default node

and then you'll need to run

nvm use default

or exit and open a new tab


Failed to load plugin '@next/next' declared in '.eslintrc.js


its due to different versions of nodejs

  • I installed nvm and updated nodejs from version 12.22 to to version 18.6.0 then deployed it for the other users (gitlab-runner)

    n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; cp -r $n/{bin,lib,share} /usr/local



  • I removed the node_modules folder with rm -r node_modules an reinstalled with npm install



root@server:/home/cloudvariation.in/public_html/blogar# npm start

> blogar@0.1.0 start
> next start

ready - started server on 0.0.0.0:3001, url: http://localhost:3001
/home/cloudvariation.in/public_html/blogar/.next/server/pages/_document.js:27
                        href: `${ true ? process.env.NEXT_PUBLIC_BASEPATH ?? "" : 0}/css/font-awesome.css`
                                                                           ^

SyntaxError: Unexpected token '?'

 chown -R root:nogroup blogar

fixed

Comments

Popular posts from this blog

cpanel exam CPSP Answers

How to install zimbra collaboration suite 8.8.11 on CentOS 7

awstats installation