うまくいかない例
```
0 * * * * cd /home/pi/bin/vercel-nostr-posts && npm run deploy > /dev/null 2>&1
```
`/usr/bin` の node と npm が使用されるため、うまくいかない
#NodeJS #RaspberryPi
うまくいかない例
```
0 * * * * cd /home/pi/bin/vercel-nostr-posts && npm run deploy > /dev/null 2>&1
```
`/usr/bin` の node と npm が使用されるため、うまくいかない
#NodeJS #RaspberryPi
`/usr/local/bin` からのフルパスで npm を記載
```
0 * * * * cd /home/pi/bin/vercel-nostr-posts && /usr/local/bin/npm run deploy > /dev/null 2>&1
```
以下のエラーが発生する
```
ERROR: npm v9.3.1 is known not to run on Node.js v12.22.12. You'll need to
upgrade to a newer Node.js version in order to use this version of npm. This
version of npm supports the following node versions: `^14.17.0 || ^16.13.0 ||
>=18.0.0`. You can find the latest version at https://nodejs.org/.
```
`/usr/bin` の node が使用されるため、うまくいかない
#NodeJS #RaspberryPi
PATH に `/usr/local/bin` を追加する
```
0 * * * * PATH=/usr/local/bin/:$PATH cd /home/pi/bin/vercel-nostr-posts && /usr/local/bin/npm run deploy > /dev/null 2>&1
```
エラーは変わらない
```
ERROR: npm v9.3.1 is known not to run on Node.js v12.22.12. You'll need to
upgrade to a newer Node.js version in order to use this version of npm. This
version of npm supports the following node versions: `^14.17.0 || ^16.13.0 ||
>=18.0.0`. You can find the latest version at https://nodejs.org/.
```
シェル変数 (`PATH=/usr/local/bin/:$PATH`) は子プロセスには受け渡されないため、うまくいかない
#NodeJS #RaspberryPi