Note that I was addicted to npm script not passing in the verification environment

What i wanted to do

I wanted to prepare a front environment for the verification environment of a project that has been released and is in production.

What i did

--Enter the verification environment and git clone --Like local npm run dev

What happened

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)

Preparation of node_module

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

Works on local environment but not on test or staging server

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.

Log error check

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.

Is the added package listed in package.json?

Local and verification environment respectively I tried to output with $ vi package.json, but there was no problem.

Is the package required for production written in devDependencies?

I also checked this, but there was no problem.

Whether node and npm versions are the same

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.

install nodebrew

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)

npm script execution

I passed the npm script safely! !! !! !!

Summary

--Prepare node_modules --Align node and npm versions --Insert nodebrew

that's all!

SpecialThanks: tweeeety

Recommended Posts

Note that I was addicted to npm script not passing in the verification environment
Note that I was addicted to sklearn's missing value interpolation (Imputer)
Note that I was addicted to accessing the DB with Python's mysql.connector using a web application.
The file name was bad in Python and I was addicted to import
What I was addicted to when creating a web application in a windows environment
[Words spelled to me when I was in the first grade ①] I'm not afraid to build a programming environment.
I thought it was the same as python, and I was addicted to the problem that the ruby interpreter did not start.
I was addicted to scraping with Selenium (+ Python) in 2020
A story that I was addicted to at np.where
I was addicted to trying logging.getLogger in Flask 1.1.x
I was soberly addicted to calling awscli from a Python 2.7 script registered in crontab
I wrote a script that splits the image in two
When I tried to install PIL and matplotlib in a virtualenv environment, I was addicted to it.
What I was addicted to when dealing with huge files in a Linux 32bit environment
I was in charge of maintaining the Fabric script, but I don't know.> <To those who
The story I was addicted to when I specified nil as a function argument in Go
A story that I was addicted to calling Lambda from AWS Lambda.
The story that the version of python 3.7.7 was not adapted to Heroku
The record I was addicted to when putting MeCab on Heroku
What I was addicted to with json.dumps in Python base64 encoding
A note I was addicted to when making a beep on Linux
LINEbot development, I want to check the operation in the local environment
A note I was addicted to when creating a table with SQLAlchemy
I was addicted to confusing class variables and instance variables in Python
I was addicted to multiprocessing + psycopg2
[Fabric] I was addicted to using boolean as an argument, so make a note of the countermeasures.
Numpy's intellisense (input completion) is incomplete in VS Code and I was lightly addicted to the solution
I want to load the pytest fixture as a library somewhere else (pytest may not exist in the environment)
I was addicted to creating a Python venv environment with VS Code
Commands that were important when building the Laravel environment in the Apache environment (Note)
I was addicted to not being able to use Markdown on pypi's long_description
[Python] I was addicted to not saving internal variables of lambda expressions
I was addicted to trying Cython with PyCharm, so make a note
I was addicted to pip install mysqlclient
I was addicted to Flask on dotCloud
What I was addicted to Python autorun
Log when I was worried that I could not connect to Wi-Fi on Linux
I want to use Python in the environment of pyenv + pipenv on Windows 10
I was in trouble because the behavior of docker container did not change
I tried to predict the horses that will be in the top 3 with LightGBM
Note that I understand the least squares algorithm. And I wrote it in Python.
AtCoder AGC 041 C --I was addicted to the full search of Domino Quality
I wrote a script to revive the gulp watch that will die soon
A note I was addicted to when running Python with Visual Studio Code
A story that I was addicted to when I made SFTP communication with python
I set up TensowFlow and was addicted to it, so make a note
[Introduction to json] No, I was addicted to it. .. .. ♬
I was able to recurse in Python: lambda
I wrote "Introduction to Effect Verification" in Python
I want to display the progress in Python!
[Jinja2] Solution to the problem that variables added in the for statement are not inherited
[Django] Let's try to clarify the part of Django that was somehow through in the test
I tried to score the syntax that was too humorous and humorous using the COTOHA API.
[Pyhton] I want to solve the problem that tkinter does not work on MacOS11
After implementing Watson IoT Platform application in Flask, I was addicted to MQTT connection
What I was addicted to when combining class inheritance and Joint Table Inheritance in SQLAlchemy
Here is one of the apps with "artificial intelligence" that I was interested in.
What I did when I was angry to put it in with the enable-shared option
Note that the method of publishing modules to PyPI has changed in various ways.
Code memo that I was having trouble with not being on the discord.py site
Solved the problem that the image was not displayed in ROMol when loaded with PandasTools.LoadSDF.