I wanted to prepare a front environment for the verification environment of a project that has been released and is in production.
--Enter the verification environment and git clone
--Like local npm run dev
sh: next: Command not found
I read the error statement for the time being. (Repository name is changed to hoge)
$ npm run dev
sh: next:Command not found
npm ERR! Linux 3.10.0-862.11.6.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
npm ERR! node v6.16.0
npm ERR! npm v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] dev: `next -p 8080`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] dev script 'next -p 8080'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the hoge package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! next -p 8080
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs hoge
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls hoge
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! Please include the following file with any support request:
npm ERR! /var/www/apps/hoge/npm-debug.log
Local package.json exists, but node_modules missing, did you mean to install?
I have package.json, but I don't have node_modules, why not install it? Since it is said something like, prepare node_modules.
(It's because node_modules ignores w)
npm install
Just in case, check the version with node -v
$ node -v
v6.16.0
I was able to confirm that it was included, so again npm run dev
(At the very beginning, when I ran npm run dev
, it was before npm install
, so it didn't work.)
The previous error has disappeared
$ npm run dev
npm ERR! Linux 3.10.0-862.11.6.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
npm ERR! node v6.16.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] dev: `next -p 8080`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script 'next -p 8080'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the hoge package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! next -p 8080
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs hoge
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls hoge
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /var/www/apps/hoge/npm-debug.log
Failed at the [email protected] dev script 'next -p 8080'.
script is said to have failed
When I was researching, I came to a wonderful place where things to do in similar situations are listed. I tried it one by one.
To the previous error
Please include the following file with any support request: /var/www/apps/hoge/npm-debug.log
Check with $ vi npm-debug.log
(Displayed only after error)
[Addition] After publishing the article, he pointed out that it is generally better to check the log with cat or less or tail! It seems that if you open the log confirmation with an editor etc., there is a risk of modification or deletion and it is dangerous. For details, click here Commands often used when checking logs in operations and surveys (2020.02.27)
17 error Linux 3.10.0-862.11.6.el7.x86_64
18 error argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
19 error node v6.16.0
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error [email protected] dev: `next -p 8080`
22 error Exit status 1
23 error Failed at the [email protected] dev script 'next -p 8080'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the hoge package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error next -p 8080
23 error You can get information on how to open an issue for this project with:
23 error npm bugs hoge
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls hoge
23 error There is likely additional logging output above.
It's almost the same as the error statement above.
Local and verification environment respectively
I tried to output with $ vi package.json
, but there was no problem.
I also checked this, but there was no problem.
Check version for the time being
$ npm -v
3.10.10
$ node -v
v6.16.0
It was suspicious and it was quite old, so for the time being, to adjust it locally
$ nodebrew use v10.15.3
(Since the version of npm goes up according to the version of node, it will be forced to the same version)
[Addition] After publishing the article, he pointed out that it is bad to match the local environment with the verification environment, and it is better to match the local environment with the verification environment. If you want to change the version of the verification environment, it seems better to create a "verification environment version up task" and do it carefully! And if it has already been released, it seems that the main premise is to build the environment based on the production environment. (2020.02.27)
-bash: nodebrew: command not found
Since nodebrew is not included, I will include it.
I will try it according to the official nodebrew. Click here for details (The .bash_profile part is a SHELL setting, so change it to .bashrc or .zshrc)
$ curl -L git.io/nodebrew | perl - setup
$ vi .bash_profile
$ source ~/.bash_profile
Run again
$ nodebrew use v10.15.3
v10.15.3
I got the version of node! Also check the version of npm.
$ npm -v
6.4.1
The version of npm has also been upgraded! !! (This time, I just passed the npm script, so I haven't actually accessed it yet)
I passed the npm script safely! !! !! !!
--Prepare node_modules --Align node and npm versions --Insert nodebrew
that's all!
SpecialThanks: tweeeety
Recommended Posts