問題
npm install
遇到 no such file or directory,原因是沒有 package.json。
錯誤訊息:
vagrant@homestead:~/code/redis-test$ npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/watchpack/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/vagrant/code/redis-test/node_modules/webpack-dev-server/node_modules/is-absolute-url/package.json.3672698083
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/vagrant/code/redis-test/node_modules/webpack-dev-server/node_modules/is-absolute-url/package.json.3672698083'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2020-09-03T02_30_49_347Z-debug.log
解決
npm init -y
產生 package.json