Nuxt.js project deployment issues

The configuration in

clipboard.png
package.json is as follows

"scripts": {
    "dev": "nuxt",
    "build": "cross-env NODE_ENV=production nuxt build && nuxt start",
    "start": "nuxt start",
    "server": "cross-env NODE_ENV=production nodemon server --exec babel-node --presets es2015,stage-2",
    "online": "babel server -d dist --presets es2015,stage-2",
    "serve": "cross-env NODE_ENV=production pm2 start dist/index.js",
    "generate": "nuxt generate",
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
    "precommit": "npm run lint"
  }

if the packaged .nuxt folder has only these files and no static resources such as pictures, you will not be able to run at all. Which folders need to be uploaded to the server when deploying here

Aug.18,2021

npm install


these are just intermediate files.


it is officially recommended to use two commands: next build;next start
to a portal to see if they can help you: next.js, nuxt.js and other server rendering frameworks built projects are deployed to the server


.

all files, including node_modules , must also be uploaded to the server
because they are server-side rendering, so these components are all required

you can try to run with pm2 on this machine first

the deployment was successful only yesterday, and the specific principle is not understood


Hello, landlord! The following excerpt is from eggjs application deployment

the JavaScript language itself does not need to be compiled, and the build process is mainly a download dependency. However, this step is necessary if you use TypeScript or Babel to support ES6 features.

General installation dependencies specify NODE_ENV=production or npm install-- production to install only dependencies dependencies. Unknown problems may also be encountered after installation because the modules in devDependencies are too large and will not be used in a production environment.

$ cd baseDir
$ npm install --production
$ tar -zcvf ../release.tgz .

after the build is completed, it is packaged into a tgz file, and then unzipped and started during deployment.

< hr >

if it is helpful, please click to adopt it, thank you ~


static resources such as images are launched after the
nuxt project is launched in the .nuxt / dist/ directory. You can use services such as nginx to forward the request to the corresponding node port.
the files you need to launch are only .nuxt and build folders. Of course, to run the node service, you also need node_modules (this can also be packaged together, if it is too large. You can install dependencies on the server
because our company's server resources are limited, we cannot build files on the server. We select the local build, and upload the packaged files to the server. The server pulls the project code (git), and decompresses the uploaded build+.nuxt package at the same time, and then starts the node service with pm2, so that we can access the
locally executed code

.
"scripts": {
    "dev": "backpack dev",
    "build": "nuxt build && backpack build"
    }
//shell
rm -rf .nuxt/
rm -rf build/
rm -rf node_modules/
cnpm install
npm run build
rm -rf new.tar.gz
tar -zcvf new.tar.gz .nuxt/ build/
scp tar

Server executes script

cd 
git pull
cnpm install
rm -rf .nuxt/ build/
tar -zxvf new.tar.gz
pm2 -o /dev/null start build/main.js --name 

if your server supports online compilation, package
you can set the npm command directly in package.json

"start:test": "cross-env _ENV=test pm2 start build/main.js --node-args='--harmony' --name 'project_name'",
"start:production": "cross-env _ENV=production pm2 start build/main.js --node-args='--harmony' --name 'project_name'"

the server can execute different scripts according to different environments

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e48c3d-44ce2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e48c3d-44ce2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?