mapconcierge / til

TIL - Today I Learned
Creative Commons Zero v1.0 Universal
0 stars 3 forks source link

Node.JS インストール MEMO #7

Open mapconcierge opened 3 years ago

mapconcierge commented 3 years ago

Node.JS のインストール https://nodejs.org/ja/download/

最新のバージョン: 14.15.0 for Mac を使用。

mapconcierge commented 3 years ago

This package has installed: • Node.js v14.15.0 to /usr/local/bin/node • npm v6.14.8 to /usr/local/bin/npm Make sure that /usr/local/bin is in your $PATH.

スクリーンショット 2020-11-04 7 21 38

mapconcierge commented 3 years ago

最新版のnpmをインストールするとEACCESエラーが出る https://qiita.com/tkinoshi726/items/a32e31bc42a662371a8e

aoyamagcbookea3:~ taichi$ npm install -g gatsby-cli
npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/taichi/.npm/_logs/2020-11-03T22_23_28_727Z-debug.log

sudo コマンドをつけて実行することで解決。

aoyamagcbookea3:~ taichi$ sudo npm install -g gatsby-cli
Password:
npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
/usr/local/bin/gatsby -> /usr/local/lib/node_modules/gatsby-cli/cli.js

> core-js@2.6.11 postinstall /usr/local/lib/node_modules/gatsby-cli/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

> gatsby-telemetry@1.3.39 postinstall /usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry
> node src/postinstall.js || true

> gatsby-cli@2.12.115 postinstall /usr/local/lib/node_modules/gatsby-cli
> node scripts/postinstall.js

+ gatsby-cli@2.12.115
added 597 packages from 532 contributors in 32.045s
aoyamagcbookea3:~ taichi$ 
aoyamagcbookea3:~ taichi$ 
aoyamagcbookea3:~ taichi$  which npm
/usr/local/bin/npm
mapconcierge commented 3 years ago

以下のエラーが出たので Xcode のインストール

Error: Command failed with exit code 1: git clone https://github.com/gatsbyjs/ gatsby-starter-hello-world.git gatsby-site --recursive --depth=1

aoyamagcbookea3:~ taichi$ sudo gatsby new gatsby-site https://github.com/gatsbyjs/gatsby-starter-hello-world
Password:
info Creating new site from git: https://github.com/gatsbyjs/gatsby-starter-hello-world.git
xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.
error Command failed with exit code 1: git clone https://github.com/gatsbyjs/gatsby-starter-hello-world.git gatsby-site --recursive --depth=1

  Error: Command failed with exit code 1: git clone https://github.com/gatsbyjs/  gatsby-starter-hello-world.git gatsby-site --recursive --depth=1

  - error.js:56 makeError
    [lib]/[gatsby-cli]/[execa]/lib/error.js:56:11

  - index.js:114 handlePromise
    [lib]/[gatsby-cli]/[execa]/index.js:114:26

  - task_queues.js:93 processTicksAndRejections
    internal/process/task_queues.js:93:5

  - init-starter.js:204 clone
    [lib]/[gatsby-cli]/lib/init-starter.js:204:3

  - init-starter.js:350 initStarter
    [lib]/[gatsby-cli]/lib/init-starter.js:350:5

  - create-cli.js:443 
    [lib]/[gatsby-cli]/lib/create-cli.js:443:7

スクリーンショット 2020-11-04 9 02 43

mapconcierge commented 3 years ago

Gatsby.js の動作テスト

develop も build も sudo コマンドが必要になった。

aoyamagcbookea3:gatsby-site taichi$ gatsby develop
error Looks like develop for this site is already running, can you visit http://localhost:8000 ? If it is not, try again in five seconds!
aoyamagcbookea3:gatsby-site taichi$ 
aoyamagcbookea3:gatsby-site taichi$ 
aoyamagcbookea3:gatsby-site taichi$ 
aoyamagcbookea3:gatsby-site taichi$ cd ..
aoyamagcbookea3:~ taichi$ ls
Applications    Documents   Library     Music       Public
Desktop     Downloads   Movies      Pictures    gatsby-site
aoyamagcbookea3:~ taichi$ which gatsby
/usr/local/bin/gatsby
aoyamagcbookea3:~ taichi$ cd gatsby-site/
aoyamagcbookea3:gatsby-site taichi$ ls
LICENSE         gatsby-config.js    package-lock.json   src
README.md       node_modules        package.json        static
aoyamagcbookea3:gatsby-site taichi$ sudo gatsby develop
Password:
success open and validate gatsby-configs - 0.020s
success load plugins - 0.158s
success onPreInit - 0.026s
success initialize cache - 0.010s
success copy gatsby files - 0.171s
success onPreBootstrap - 0.034s
success createSchemaCustomization - 0.003s
success Checking for changed pages - 0.001s
success source and transform nodes - 0.036s
success building schema - 0.221s
info Total nodes: 18, SitePage nodes: 1 (use --verbose for breakdown)
success createPages - 0.011s
success Checking for changed pages - 0.000s
success createPagesStatefully - 0.048s
success update schema - 0.024s
success write out redirect data - 0.001s
success onPostBootstrap - 0.032s
info bootstrap finished - 8.032s
success onPreExtractQueries - 0.001s
success extract queries from components - 0.104s
success write out requires - 0.009s
success run page queries - 0.022s - 2/2 92.42/s
⠀
You can now view gatsby-starter-hello-world in the browser.
⠀
  http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
  http://localhost:8000/___graphql
⠀
Note that the development build is not optimized.
To create a production build, use gatsby build
⠀
success Building development bundle - 9.976s
^Caoyamagcbookea3:gatsby-site taichi$ 
aoyamagcbookea3:gatsby-site taichi$ 
aoyamagcbookea3:gatsby-site taichi$ gatsby build
success open and validate gatsby-configs - 0.014s
success load plugins - 0.132s
success onPreInit - 0.030s
error EACCES: permission denied, unlink '/Users/taichi/gatsby-site/public/index.html'

  Error: EACCES: permission denied, unlink '/Users/taichi/gatsby-site/public/index.html'

not finished delete html and css files from previous builds - 0.195s
aoyamagcbookea3:gatsby-site taichi$ sudo gatsby build
success open and validate gatsby-configs - 0.014s
success load plugins - 0.136s
success onPreInit - 0.025s
success delete html and css files from previous builds - 0.007s
success initialize cache - 0.005s
success copy gatsby files - 0.190s
success onPreBootstrap - 0.031s
success createSchemaCustomization - 0.001s
success Checking for changed pages - 0.000s
success source and transform nodes - 0.062s
success building schema - 0.288s
info Total nodes: 18, SitePage nodes: 1 (use --verbose for breakdown)
success createPages - 0.003s
success Checking for changed pages - 0.000s
success createPagesStatefully - 0.045s
success Cleaning up stale page-data - 0.002s
success update schema - 0.023s
success onPreExtractQueries - 0.000s
success extract queries from components - 0.018s
success write out redirect data - 0.001s
success onPostBootstrap - 0.000s
info bootstrap finished - 12.530s
success run page queries - 0.013s - 1/1 74.89/s
success write out requires - 0.005s
success Building production JavaScript and CSS bundles - 9.328s
success Rewriting compilation hashes - 0.004s
success Building static HTML for pages - 0.894s - 1/1 1.12/s
success onPostBuild - 0.000s
info Done building in 22.873206438 sec
aoyamagcbookea3:gatsby-site taichi$ gatsby serve
⠀
You can now view gatsby-starter-hello-world in the browser.
⠀
  http://localhost:9000/
^C
aoyamagcbookea3:gatsby-site taichi$ 

スクリーンショット 2020-11-04 9 41 44