npm script throws an error, but doesn't give anything useful - javascript

Attempting to run jest and see if my tests pass. However, running jest instead gives me this very cryptic error. Is there any way to get something useful out of node error messages or am I just not able to read this correctly?
0 info it worked if it ends with ok
1 verbose cli [ '/home/ec2-user/.nvm/versions/node/v10.4.0/bin/node',
1 verbose cli '/home/ec2-user/.nvm/versions/node/v10.4.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'test' ]
2 info using npm#6.1.0
3 info using node#v10.4.0
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle api_rule_template#0.0.0-beta~pretest: api_rule_template#0.0.0-beta
6 info lifecycle api_rule_template#0.0.0-beta~test: api_rule_template#0.0.0-beta
7 verbose lifecycle api_rule_template#0.0.0-beta~test: unsafe-perm in lifecycle true
8 verbose lifecycle api_rule_template#0.0.0-beta~test: PATH: /home/ec2-user/.nvm/versions/node/v10.4.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ec2-user/environment/api_rule_template/node_modules/.bin:/home/ec2-user/.nvm/versions/node/v10.4.0/bin:/usr/local/rvm/gems/ruby-2.4.1/bin:/usr/local/rvm/gems/ruby-2.4.1#global/bin:/usr/local/rvm/rubies/ruby-2.4.1/bin:/usr/local/bin:/bin:/usr/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/opt/aws/bin:/usr/local/rvm/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin
9 verbose lifecycle api_rule_template#0.0.0-beta~test: CWD: /home/ec2-user/environment/api_rule_template
10 silly lifecycle api_rule_template#0.0.0-beta~test: Args: [ '-c', 'jest' ]
11 silly lifecycle api_rule_template#0.0.0-beta~test: Returned: code: 1 signal: null
12 info lifecycle api_rule_template#0.0.0-beta~test: Failed to exec test script
13 verbose stack Error: api_rule_template#0.0.0-beta test: `jest`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/home/ec2-user/.nvm/versions/node/v10.4.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:304:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.<anonymous> (/home/ec2-user/.nvm/versions/node/v10.4.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:961:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
14 verbose pkgid api_rule_template#0.0.0-beta
15 verbose cwd /home/ec2-user/environment/api_rule_template
16 verbose Linux 4.14.33-51.37.amzn1.x86_64
17 verbose argv "/home/ec2-user/.nvm/versions/node/v10.4.0/bin/node" "/home/ec2-user/.nvm/versions/node/v10.4.0/bin/npm" "run" "test"
18 verbose node v10.4.0
19 verbose npm v6.1.0
20 error code ELIFECYCLE
21 error errno 1
22 error api_rule_template#0.0.0-beta test: `jest`
22 error Exit status 1
23 error Failed at the api_rule_template#0.0.0-beta test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

So the answer. The problem was that there was a database connection being attempted to port 3306 for MySQL instead of using SQLite because an environment variable wasn't being set.
Instead of telling me that, Jest would just silently exit instead, even running jest from the global command line. Even turning on verbose/debug didn't help with that problem.
The way I discovered it was by installing the expect global package and writing a few wrapper shims around describe and it. Then running that through node directly instead of through Jest showed the actual error.
I'm guessing this is a Jest bug.

Related

`21 error errno 1 22 error my-app#0.1.0 start: `react-scripts start` 22 error Exit status 1` Error while starting react-js

I'm trying to launch a react-js app and it keeps saying this
0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ] 2 info using npm#6.14.4 3 info using node#v10.19.0 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle my-app#0.1.0~prestart: my-app#0.1.0 6 info lifecycle my-app#0.1.0~start: my-app#0.1.0 7 verbose lifecycle my-app#0.1.0~start: unsafe-perm in lifecycle true 8 verbose lifecycle my-app#0.1.0~start: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/filipthedev/my-app/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin 9 verbose lifecycle my-app#0.1.0~start: CWD: /home/filipthedev/my-app 10 silly lifecycle my-app#0.1.0~start: Args: [ '-c', 'react-scripts start' ] 11 silly lifecycle my-app#0.1.0~start: Returned: code: 1 signal: null 12 info lifecycle my-app#0.1.0~start: Failed to exec start script 13 verbose stack Error: my-app#0.1.0 start: react-scripts start13 verbose stack Exit status 1 13 verbose stack at EventEmitter.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:198:13) 13 verbose stack at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:198:13) 13 verbose stack at maybeClose (internal/child_process.js:982:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5) 14 verbose pkgid my-app#0.1.0 15 verbose cwd /home/filipthedev/my-app 16 verbose Linux 5.15.0-50-generic 17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start" 18 verbose node v10.19.0 19 verbose npm v6.14.4 20 error code ELIFECYCLE 21 error errno 1 22 error my-app#0.1.0 start:react-scripts start 22 error Exit status 1 23 error Failed at the my-app#0.1.0 start script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]
My npm and node are updated to the latest versions. Can you help me?

error in react.js when clicking npm start [duplicate]

This question already has answers here:
Nodemon Error: "System limit for number of file watchers reached"
(11 answers)
Closed 1 year ago.
first of all I created a todo app in react.js with the command: npx create-react-app app_name
after running the command npm start, it displayed this errors to me:
after that I found a log file wich has all these lines that I didn't understand anything from them:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/home/amarmahdi/.nvm/versions/node/v14.17.0/bin/node',
1 verbose cli '/home/amarmahdi/.nvm/versions/node/v14.17.0/bin/npm',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm#6.14.13
3 info using node#v14.17.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle inventory#0.1.0~prestart: inventory#0.1.0
6 info lifecycle inventory#0.1.0~start: inventory#0.1.0
7 verbose lifecycle inventory#0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle inventory#0.1.0~start: PATH: /home/amarmahdi/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/amarmahdi/developement/reactTutorial/inventory/node_modules/.bin:/home/amarmahdi/.nvm/versions/node/v14.17.0/bin:/home/amarmahdi/.sdkman/candidates/java/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle inventory#0.1.0~start: CWD: /home/amarmahdi/developement/reactTutorial/inventory
10 silly lifecycle inventory#0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle inventory#0.1.0~start: Returned: code: 1 signal: null
12 info lifecycle inventory#0.1.0~start: Failed to exec start script
13 verbose stack Error: inventory#0.1.0 start: react-scripts start
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/home/amarmahdi/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:376:20)
13 verbose stack at ChildProcess. (/home/amarmahdi/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:376:20)
13 verbose stack at maybeClose (internal/child_process.js:1055:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid inventory#0.1.0
15 verbose cwd /home/amarmahdi/developement/reactTutorial/inventory
16 verbose Linux 5.4.0-74-generic
17 verbose argv "/home/amarmahdi/.nvm/versions/node/v14.17.0/bin/node" "/home/amarmahdi/.nvm/versions/node/v14.17.0/bin/npm" "start"
18 verbose node v14.17.0
19 verbose npm v6.14.13
20 error code ELIFECYCLE
21 error errno 1
22 error inventory#0.1.0 start: react-scripts start
22 error Exit status 1
23 error Failed at the inventory#0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
for the operating system I'm using ubuntu 18.04 and for node I'm using node version manager, with node version 14.17.0.
I hope that there will be some answers about this question.
This is because Linux internally observes the number of times file is watched.
Well, you can override the limit by doing
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
in your terminal.

Why My Node Package Manager is giving me error after installing it and after running the pacakage.JSON file?

i am learning node.js. I initialized a package.json file in my project and I used a special lifecycle script "start" in my JSON file. Before initializing npm I ran "node app.js" command in terminal to run the code inside app.js. But when I ran the code using NPM, I am getting an error after running this command:
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/apple/.npm/_logs/2021-02-01T15_18_14_323Z-debug.log
here are the contents of the log file:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/Users/apple/.nvm/versions/node/v14.7.0/bin/node',
1 verbose cli '/Users/apple/.nvm/versions/node/v14.7.0/bin/npm',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm#6.14.7
3 info using node#v14.7.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle guide#1.0.0~prestart: guide#1.0.0
6 info lifecycle guide#1.0.0~start: guide#1.0.0
7 verbose lifecycle guide#1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle guide#1.0.0~start: PATH: /Users/apple/.nvm/versions/node/v14.7.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/apple/Desktop/guide/node_modules/.bin:/Users/apple/.nvm/versions/node/v14.7.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands
9 verbose lifecycle guide#1.0.0~start: CWD: /Users/apple/Desktop/guide
10 silly lifecycle guide#1.0.0~start: Args: [ '-c', 'node app.js' ]
11 silly lifecycle guide#1.0.0~start: Returned: code: 1 signal: null
12 info lifecycle guide#1.0.0~start: Failed to exec start script
13 verbose stack Error: guide#1.0.0 start: `node app.js`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/Users/apple/.nvm/versions/node/v14.7.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:314:20)
13 verbose stack at ChildProcess.<anonymous> (/Users/apple/.nvm/versions/node/v14.7.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:314:20)
13 verbose stack at maybeClose (internal/child_process.js:1051:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid guide#1.0.0
15 verbose cwd /Users/apple/Desktop/guide
16 verbose Darwin 17.7.0
17 verbose argv "/Users/apple/.nvm/versions/node/v14.7.0/bin/node" "/Users/apple/.nvm/versions/node/v14.7.0/bin/npm" "start"
18 verbose node v14.7.0
19 verbose npm v6.14.7
20 error code ELIFECYCLE
21 error errno 1
22 error guide#1.0.0 start: `node app.js`
22 error Exit status 1
23 error Failed at the guide#1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
You should write start like this : "start" : "node app.js". And you must install node_modules. For that you can write console npm i. Modules will install and it should not be a problem.
There are many things to do for creating a start script:
First things first, to initialize a node and npm project, there has to be a package.json file. It can be created manually, but it is advisable to use the command npm init in the terminal. This command walks you through creating a package.json file asking some questions. You can simply press enter, enter, if you want, but you could also answer them, no problem. You can also skip everything by running npm init -y instead of npm init.
Second, you have to create a script using the scripts object only, not anywhere else. To do that, open the file in your editor, look at where the object resides, or create a new object:
{
"name": "your-app",
"version": "0.0.1",
"main": "index.js",
"license": "ISC",
"scripts": {
"start": "node app.js" // here
}
}
Finally, run the script using the command npm run start in the terminal.

Plesk Obsidian, IISNode and Express problem - application only works locally

I have installed a Node.JS + Expres.JS application on my server, with IISNode and Plesk Obsidian. When I surf the page in my browser I get this error:
I have already checked the permissions of the respective folders and the respective "App Identities" have the necessary permissions. Every time I start my application, the following error message is written to the log:
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'start'
1 verbose cli ]
2 info using npm#6.13.4
3 info using node#v12.15.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle lynx#0.0.0~prestart: lynx#0.0.0
6 info lifecycle lynx#0.0.0~start: lynx#0.0.0
7 verbose lifecycle lynx#0.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle lynx#0.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Inetpub\vhosts\kiseni.com\test.kiseni.com\node_modules\.bin;C:\Program Files\nodejs;C:\Program Files (x86)\Mail Enable\BIN;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Mail Enable\BIN64;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Plesk\ctl;C:\Program Files\nodejs\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\.dotnet\tools;C:\Windows\system32\config\systemprofile\AppData\Roaming\npm;C:\Users\kiseniadmin\AppData\Local\Microsoft\WindowsApps
9 verbose lifecycle lynx#0.0.0~start: CWD: C:\Inetpub\vhosts\kiseni.com\test.kiseni.com
10 silly lifecycle lynx#0.0.0~start: Args: [ '/d /s /c', 'node ./bin/www' ]
11 silly lifecycle lynx#0.0.0~start: Returned: code: 1 signal: null
12 info lifecycle lynx#0.0.0~start: Failed to exec start script
13 verbose stack Error: lynx#0.0.0 start: `node ./bin/www`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:223:5)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:223:5)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid lynx#0.0.0
15 verbose cwd C:\Inetpub\vhosts\kiseni.com\test.kiseni.com
16 verbose Windows_NT 10.0.14393
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "start"
18 verbose node v12.15.0
19 verbose npm v6.13.4
20 error code ELIFECYCLE
21 error errno 1
22 error lynx#0.0.0 start: `node ./bin/www`
22 error Exit status 1
23 error Failed at the lynx#0.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
The funny part is that after this error the application is available locally on the server at localhost:3000, but outside the application still has the iisnode error from the first screenshot
I am grateful for any help!
The substatus 1002 is IISNODE_ERROR_PIPE_CONNECTION_BEFORE_PROCESS_TERMINATED. This means your process has terminated, so iisnode cannot pipe data to your node process. Your logs confirm that indeed your process is not starting successfully.
You need to figure out why your node process fails to start. Adding some logging to see how far you get before it crashes will help.

Nuxt.js Failed dev script

I have a site that i've been building using Nuxt.js and I've been loving everything about it but i can't seem to figure out why i'm receiving the following error when I try $npm run dev
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'dev' ]
2 info using npm#6.1.0
3 info using node#v8.11.2
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle carlinfitness#1.0.0~predev: carlinfitness#1.0.0
6 info lifecycle carlinfitness#1.0.0~dev: carlinfitness#1.0.0
7 verbose lifecycle carlinfitness#1.0.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle carlinfitness#1.0.0~dev: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/zac/code/carlinFitness/node_modules/.bin:/home/zac/bin:/home/zac/.local/bin:/home/zac/bin:/home/zac/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle carlinfitness#1.0.0~dev: CWD: /home/zac/code/carlinFitness
10 silly lifecycle carlinfitness#1.0.0~dev: Args: [ '-c', 'nuxt' ]
11 silly lifecycle carlinfitness#1.0.0~dev: Returned: code: 1 signal: null
12 info lifecycle carlinfitness#1.0.0~dev: Failed to exec dev script
13 verbose stack Error: carlinfitness#1.0.0 dev: `nuxt`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:304:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid carlinfitness#1.0.0
15 verbose cwd /home/zac/code/carlinFitness
16 verbose Linux 4.13.0-43-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
18 verbose node v8.11.2
19 verbose npm v6.1.0
20 error code ELIFECYCLE
21 error errno 1
22 error carlinfitness#1.0.0 dev: `nuxt`
22 error Exit status 1
23 error Failed at the carlinfitness#1.0.0 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
I concur with Sk_. That error message is caused by a process that is running on port 3000. In may case, I entered http://localhost:3000 in my browser's address bar and behold, my database monitor came up! I then shut the monitor down and tried again. This time, $npm run dev ran without a hitch.
Michael

Categories