jackieli123723 / jackieli123723.github.io

✅lilidong 个人博客
9 stars 0 forks source link

nuxt-seo #55

Open jackieli123723 opened 6 years ago

jackieli123723 commented 6 years ago

通过查看nuxt.js工程目录下的package.json文件,我们可以看到下列几条指令:

"scripts": {
  "dev": "nuxt",
  "build": "nuxt build",
  "start": "nuxt start",
  "generate": "nuxt generate"
}
结合官网的介绍,我们可以知道不同的指令对应着不同的功能:

指令 | 描述
-- | --
nuxt | 开启一个监听3000端口的服务器,同时提供hot-reloading功能
nuxt build | 构建整个应用,压缩合并JS和CSS文件(用于生产环境)
nuxt start | 开启一个生产模式的服务器(必须先运行nuxt build命令)
nuxt generate | 构建整个应用,并为每一个路由生成一个静态页面(用于静态服务器)
^Cgangans-MacBook:nuxt-test gangan$ n 8.1.2

     install : node-v8.1.2
       mkdir : /usr/local/n/versions/node/8.1.2
       fetch : https://nodejs.org/dist/v8.1.2/node-v8.1.2-darwin-x64.tar.gz
######################################################################## 100.0%
   installed : v8.1.2

gangans-MacBook:nuxt-test gangan$ n
node/8.1.2
gangans-MacBook:nuxt-test gangan$ node -v
v8.1.2
gangans-MacBook:nuxt-test gangan$ npm run dev

> test-project@1.0.0 dev /Users/gangan/nuxt-test
> nuxt

/Users/gangan/nuxt-test/node_modules/nuxt/lib/core/middleware/nuxt.js:72
      const policies = this.options.render.csp.policies ? {...this.options.render.csp.policies} : null
                                                           ^^^

SyntaxError: Unexpected token ...
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/gangan/nuxt-test/node_modules/nuxt/lib/core/renderer.js:19:24)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-project@1.0.0 dev: `nuxt`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the test-project@1.0.0 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!     /Users/gangan/.npm/_logs/2018-03-21T12_48_41_589Z-debug.log
gangans-MacBook:nuxt-test gangan$ n
node/8.3.0
gangans-MacBook:nuxt-test gangan$ npm run dev

> test-project@1.0.0 dev /Users/gangan/nuxt-test
> nuxt

  nuxt:build App root: /Users/gangan/nuxt-test +0ms
  nuxt:build Generating /Users/gangan/nuxt-test/.nuxt files... +2ms
  nuxt:build Generating files... +7ms
  nuxt:build Generating routes... +6ms
  nuxt:build Building files... +18ms
  nuxt:build Adding webpack middleware... +486ms
  ████████████████████ 100% 

Build completed in 2.566s

 DONE  Compiled successfully in -8431ms                                 20:49:03

 OPEN  http://localhost:3000

^Cgangans-MacBook:nuxt-test gangan$ 
gangans-MacBook:nuxt-test gangan$ atom .
-bash: atom: command not found
gangans-MacBook:nuxt-test gangan$ cat package.json 
{
  "name": "test-project",
  "version": "1.0.0",
  "description": "Nuxt.js project",
  "author": "seb1080 <sebastienblaisfernandez@gmail.com>",
  "private": true,
  "scripts": {
    "deploy": "push-dir --dir=dist --branch=gh-pages --cleanup",
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
    "precommit": "npm run lint"
  },
  "dependencies": {
    "nuxt": "^1.0.0"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.1",
    "eslint": "^4.15.0",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-vue": "^4.0.0",
    "push-dir": "^0.4.1"
  }
}
gangans-MacBook:nuxt-test gangan$ npm start

> test-project@1.0.0 start /Users/gangan/nuxt-test
> nuxt start

 ERROR 

  Error: No build files found, please run `nuxt build` before launching `nuxt st  art`

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-project@1.0.0 start: `nuxt start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the test-project@1.0.0 start 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!     /Users/gangan/.npm/_logs/2018-03-21T12_51_14_305Z-debug.log
gangans-MacBook:nuxt-test gangan$ npm run start

> test-project@1.0.0 start /Users/gangan/nuxt-test
> nuxt start

 ERROR 

  Error: No build files found, please run `nuxt build` before launching `nuxt st  art`

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-project@1.0.0 start: `nuxt start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the test-project@1.0.0 start 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!     /Users/gangan/.npm/_logs/2018-03-21T12_51_26_445Z-debug.log
gangans-MacBook:nuxt-test gangan$ n
node/8.3.0
gangans-MacBook:nuxt-test gangan$ npm run dev

> test-project@1.0.0 dev /Users/gangan/nuxt-test
> nuxt

  nuxt:build App root: /Users/gangan/nuxt-test +0ms
  nuxt:build Generating /Users/gangan/nuxt-test/.nuxt files... +2ms
  nuxt:build Generating files... +7ms
  nuxt:build Generating routes... +5ms
  nuxt:build Building files... +19ms
  nuxt:build Adding webpack middleware... +488ms
  ████████████████████ 100% 

Build completed in 2.626s

 DONE  Compiled successfully in -8371ms                                 20:51:39

 OPEN  http://localhost:3000

^Cgangans-MacBook:nuxt-test gangan$ 
gangans-MacBook:nuxt-test gangan$ ls
README.md       node_modules        plugins
assets          nuxt.config.js      static
components      package-lock.json   store
layouts         package.json
middleware      pages
gangans-MacBook:nuxt-test gangan$ clear

gangans-MacBook:nuxt-test gangan$ ls
README.md       node_modules        plugins
assets          nuxt.config.js      static
components      package-lock.json   store
layouts         package.json
middleware      pages
gangans-MacBook:nuxt-test gangan$ cat package.json 
{
  "name": "test-project",
  "version": "1.0.0",
  "description": "Nuxt.js project",
  "author": "seb1080 <sebastienblaisfernandez@gmail.com>",
  "private": true,
  "scripts": {
    "deploy": "push-dir --dir=dist --branch=gh-pages --cleanup",
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
    "precommit": "npm run lint"
  },
  "dependencies": {
    "nuxt": "^1.0.0"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.1",
    "eslint": "^4.15.0",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-vue": "^4.0.0",
    "push-dir": "^0.4.1"
  }
}
gangans-MacBook:nuxt-test gangan$ ls
README.md       node_modules        plugins
assets          nuxt.config.js      static
components      package-lock.json   store
layouts         package.json
middleware      pages
gangans-MacBook:nuxt-test gangan$ npm run build

> test-project@1.0.0 build /Users/gangan/nuxt-test
> nuxt build

  nuxt:build Building... +0ms
  nuxt:build App root: /Users/gangan/nuxt-test +0ms
  nuxt:build Generating /Users/gangan/nuxt-test/.nuxt files... +1ms
  nuxt:build Generating files... +4ms
  nuxt:build Generating routes... +7ms
  nuxt:build Building files... +18ms
  ████████████████████ 100% 

Build completed in 8.153s

 DONE  Compiled successfully in 8156ms                                  20:52:26

Hash: 19f6aa27c8e8bd01bba9
Version: webpack 3.11.0
Time: 8156ms
                                  Asset       Size  Chunks             Chunk Names
    pages/index.6033c19454b47495f579.js    4.06 kB       0  [emitted]  pages/index
layouts/default.380296134e2fbe8d4a8b.js    1.42 kB       1  [emitted]  layouts/default
         vendor.2cadf96c75822b415aba.js     143 kB       2  [emitted]  vendor
            app.e2df1bc7504217866a81.js    27.8 kB       3  [emitted]  app
       manifest.19f6aa27c8e8bd01bba9.js    1.47 kB       4  [emitted]  manifest
                               LICENSES  584 bytes          [emitted]  
 + 3 hidden assets
Hash: 07a8f4d233c9f2d4e083
Version: webpack 3.11.0
Time: 474ms
             Asset    Size  Chunks             Chunk Names
server-bundle.json  124 kB          [emitted]  
  nuxt:build Building done +9s
gangans-MacBook:nuxt-test gangan$ pwd
/Users/gangan/nuxt-test
gangans-MacBook:nuxt-test gangan$ open/gangan/
-bash: open/gangan/: No such file or directory
gangans-MacBook:nuxt-test gangan$ ll
-bash: ll: command not found
gangans-MacBook:nuxt-test gangan$ pwd
/Users/gangan/nuxt-test
gangans-MacBook:nuxt-test gangan$ open .
gangans-MacBook:nuxt-test gangan$ npm run generate

> test-project@1.0.0 generate /Users/gangan/nuxt-test
> nuxt generate

  nuxt:generate Generating... +0ms
  nuxt:build App root: /Users/gangan/nuxt-test +0ms
  nuxt:build Generating /Users/gangan/nuxt-test/.nuxt files... +0ms
  nuxt:build Generating files... +6ms
  nuxt:build Generating routes... +6ms
  nuxt:build Building files... +19ms
  ████████████████████ 100% 

Build completed in 8.148s

 DONE  Compiled successfully in 8152ms                                  20:56:53

Hash: 326781452b55c1153d37
Version: webpack 3.11.0
Time: 8152ms
                                  Asset       Size  Chunks             Chunk Names
    pages/index.6033c19454b47495f579.js    4.06 kB       0  [emitted]  pages/index
layouts/default.380296134e2fbe8d4a8b.js    1.42 kB       1  [emitted]  layouts/default
         vendor.2cadf96c75822b415aba.js     143 kB       2  [emitted]  vendor
            app.f0a10fedd48a1d779882.js    27.8 kB       3  [emitted]  app
       manifest.326781452b55c1153d37.js    1.47 kB       4  [emitted]  manifest
                               LICENSES  584 bytes          [emitted]  
 + 3 hidden assets
Hash: 78c8df4bcde16fb40984
Version: webpack 3.11.0
Time: 436ms
             Asset    Size  Chunks             Chunk Names
server-bundle.json  124 kB          [emitted]  
  nuxt: Call generate:distRemoved hooks (1) +0ms
  nuxt:generate Destination folder cleaned +9s
  nuxt: Call generate:distCopied hooks (1) +16ms
  nuxt:generate Static & build files copied +16ms
  nuxt:render Rendering url / +0ms
  nuxt: Call generate:page hooks (1) +150ms
  nuxt:generate Generate file: /index.html +150ms
  nuxt:render Rendering url / +148ms
  nuxt: Call generate:done hooks (1) +3ms
  nuxt:generate HTML Files generated in 9.3s +4ms
  nuxt:generate Generate done +0ms
gangans-MacBook:nuxt-test gangan$ ll
-bash: ll: command not found
gangans-MacBook:nuxt-test gangan$ npm install -g ssr
/usr/local/bin/ssr -> /usr/local/lib/node_modules/ssr/.bin/ssr.js
+ ssr@1.1.1
added 19 packages in 32.618s
gangans-MacBook:nuxt-test gangan$ cd dist
gangans-MacBook:dist gangan$ ls
200.html    README.md   _nuxt       favicon.ico index.html
gangans-MacBook:dist gangan$ ssr -cp 2010

  Static file server running at

=> http://localhost:2010

INFO GET 200 /index.html
INFO GET 200 /_nuxt/manifest.326781452b55c1153d37.js
INFO GET 200 /_nuxt/vendor.2cadf96c75822b415aba.js
INFO GET 200 /_nuxt/app.f0a10fedd48a1d779882.js
INFO GET 200 /_nuxt/layouts/default.380296134e2fbe8d4a8b.js
INFO GET 200 /_nuxt/pages/index.6033c19454b47495f579.js
INFO GET 200 /favicon.ico
INFO GET 200 /index.html
INFO GET 200 /_nuxt/manifest.326781452b55c1153d37.js
INFO GET 200 /_nuxt/vendor.2cadf96c75822b415aba.js
INFO GET 200 /_nuxt/app.f0a10fedd48a1d779882.js
INFO GET 200 /_nuxt/layouts/default.380296134e2fbe8d4a8b.js
INFO GET 200 /_nuxt/pages/index.6033c19454b47495f579.js
INFO GET 200 /index.html
INFO GET 200 /_nuxt/manifest.326781452b55c1153d37.js
INFO GET 200 /_nuxt/vendor.2cadf96c75822b415aba.js
INFO GET 200 /_nuxt/app.f0a10fedd48a1d779882.js
INFO GET 200 /_nuxt