"breakpoint set but not yet bound" error when debugging node.js - javascript

I have configured my Visual studio code to debug nodejs, chrome(vuejs) application using the recipe in the link. I am however getting a "Failed to exec debug script" error when I debug "Meteor All" error in visual studio code.
If I add a breakpoint in the server side code I see a "breakpoint set but not yet bound". I am however able to debug client side code correctly.
What am I missing?
Launch.json in visual studio code:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Meteor: Chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Meteor: Node",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "debug"],
"outputCapture": "std",
"port": 9229,
"timeout": 30000
}
],
"compounds": [
{
"name": "Meteor: All",
"configurations": ["Meteor: Node", "Meteor: Chrome"]
}
]
}
log in Visual Studio code:
C:\Program Files\nodejs\npm.cmd run debug
> vue-meteor-demo# debug c:\temp\vuemeteor2
> meteor run meteor --settings settings.json --inspect-brk=9229
Unknown run target: meteor
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-meteor-demo# debug: `meteor run meteor --settings settings.json --inspect-brk=9229`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-meteor-demo# debug script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\AjitGoel\AppData\Roaming\npm-cache\_logs\2019-11-14T14_17_23_502Z-debug.log
debug.log:
0 info it worked if it ends with ok
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 'debug' ]
2 info using npm#6.4.1
3 info using node#v10.15.0
4 verbose run-script [ 'predebug', 'debug', 'postdebug' ]
5 info lifecycle vue-meteor-demo#~predebug: vue-meteor-demo#
6 info lifecycle vue-meteor-demo#~debug: vue-meteor-demo#
7 verbose lifecycle vue-meteor-demo#~debug: unsafe-perm in lifecycle true
8 verbose lifecycle vue-meteor-demo#~debug: PATH: <Path>
9 verbose lifecycle vue-meteor-demo#~debug: CWD: c:\temp\vuemeteor2
10 silly lifecycle vue-meteor-demo#~debug: Args: [ '/d /s /c',
10 silly lifecycle 'meteor run meteor --settings settings.json --inspect-brk=9229' ]
11 silly lifecycle vue-meteor-demo#~debug: Returned: code: 1 signal: null
12 info lifecycle vue-meteor-demo#~debug: Failed to exec debug script
13 verbose stack Error: vue-meteor-demo# debug: `meteor run meteor --settings settings.json --inspect-brk=9229`
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:301:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
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:182:13)
13 verbose stack at maybeClose (internal/child_process.js:962:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid vue-meteor-demo#
15 verbose cwd c:\temp\vuemeteor2
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "debug"
18 verbose node v10.15.0
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error vue-meteor-demo# debug: `meteor run meteor --settings settings.json --inspect-brk=9229`
22 error Exit status 1
23 error Failed at the vue-meteor-demo# debug script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I just use --inspect, and it works fine.
I have not had success specifying the port with --inspect-brk=9229
--inspect uses port 9229 anyway
Your config for the server should be like this:
{
"type": "node",
"request": "attach",
"name": "server",
"restart": true,
"port": 9229
},
The restart option is useful while you are editing code, as it survives server restarts (by re-attaching)

It seems this message shows up if the debugger cannot "reach" the breakpoint's file through the node process the debugger is attached to.
The error message is not well covered in VS Code documentation so it's hard to find out what causes it.
I tested this by adding a file to a project, putting a breakpoint in it but not include/require'ing it anywhere. When you run the debugger (on another file) the breakpoint you just added will be "set but not yet bound".
Conversely, if you include/require the new file, the breakpoint will be normal (even if your tests never reach the line the breakpoint is on).
In my case, I inherited a codebase and found out that if your script spawns child processes (e.g. through child_process.execFile), the debugger will not track the code in the child process. Instead, it will show breakpoints as "breakpoint set but not yet bound".

Related

How do I resolve "npm run babel" error in VS code?

What am trying to do is convert modern javascript code to old code using babel.
When I hit enter on "node_modules/.bin/babel src/index.js -o dizt/azzetz/bundle.js", it works but when I include it in the package.json file then hit enter on "npm run babel" in the terminal it doesn't work.
This is the scripts object inside my "package.json" file.
"scripts": {
"babel": "node_modules/.bin/babel src/index.js -o dizt/azzetz/bundle.js"
}
When I hit enter on "npm run babel" in the terminal, I get this error below.
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 61#1.0.0 babel script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Roaming\npm-cache\_logs\2020-12-06T08_05_12_938Z-debug.log
This is my .babelrc config file.
{
"presets": ["#babel/preset-env"]
}
This is what the log file looks like.
0 info it worked if it ends with ok
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 'babel'
1 verbose cli ]
2 info using npm#6.14.8
3 info using node#v14.15.0
4 verbose run-script [ 'prebabel', 'babel', 'postbabel' ]
5 info lifecycle 61#1.0.0~prebabel: 61#1.0.0
6 info lifecycle 61#1.0.0~babel: 61#1.0.0
7 verbose lifecycle 61#1.0.0~babel: unsafe-perm in lifecycle true
8 verbose lifecycle 61#1.0.0~babel: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\user\Documents\ninja\19. Modern Workflow with Babel & Webpack\61\node_modules\.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Users\user\AppData\Local\Microsoft\WindowsApps;;C:\Users\user\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\user\AppData\Roaming\npm
9 verbose lifecycle 61#1.0.0~babel: CWD: C:\Users\user\Documents\ninja\19. Modern Workflow with Babel & Webpack\61
10 silly lifecycle 61#1.0.0~babel: Args: [ '/d /s /c', 'babel src/index.js -o dizt/azzetz/bundle.js' ]
11 silly lifecycle 61#1.0.0~babel: Returned: code: 1 signal: null
12 info lifecycle 61#1.0.0~babel: Failed to exec babel script
13 verbose stack Error: 61#1.0.0 babel: `babel src/index.js -o dizt/azzetz/bundle.js`
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:315:20)
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:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1048:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid 61#1.0.0
15 verbose cwd C:\Users\user\Documents\ninja\19. Modern Workflow with Babel & Webpack\61
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "babel"
18 verbose node v14.15.0
19 verbose npm v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error 61#1.0.0 babel: `babel src/index.js -o dizt/azzetz/bundle.js`
22 error Exit status 1
23 error Failed at the 61#1.0.0 babel script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

npm run dev execution webpack error, My webpack is newly installed

My webpack is just installed, the following is my project environment:
webpack.config.js
const path = require('path')
module.exports = {
// 打包模式
mode: "development",
// 打包入口文件
entry: path.join(__dirname, './src/index.js'),
output: {
// 输出文件路径
path: path.join(__dirname, './dist'),
// 输出文件名称
filename: 'bundle.js'
}
}
package.json
{
"name": "test_webpack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
}
}
Execute npm run dev, Output the following
λ npm run dev
> test_webpack#1.0.0 dev D:\WWW\test_webpack
> webpack
#
# Fatal error in , line 0
# Check failed: U_SUCCESS(status).
#
#
#
#FailureMessage Object: 000000A5D21ECF70npm ERR! code ELIFECYCLE
npm ERR! errno 3221225477
npm ERR! test_webpack#1.0.0 dev: `webpack`
npm ERR! Exit status 3221225477
npm ERR!
npm ERR! Failed at the test_webpack#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\cangs\AppData\Roaming\npm-cache\_logs\2019-11-19T07_20_00_087Z-debug.log
C:\Users\cangs\AppData\Roaming\npm-cache_logs\2019-11-19T07_20_00_087Z-debug.log:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'D:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'dev'
1 verbose cli ]
2 info using npm#6.9.0
3 info using node#v12.0.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle test_webpack#1.0.0~predev: test_webpack#1.0.0
6 info lifecycle test_webpack#1.0.0~dev: test_webpack#1.0.0
7 verbose lifecycle test_webpack#1.0.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle test_webpack#1.0.0~dev: PATH: D:\Users\cangs\AppData\Roaming\nvm\v12.0.0\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\WWW\test_webpack\node_modules\.bin;D:\Users\cangs\AppData\Roaming\cmder\bin;D:\Users\cangs\AppData\Roaming\cmder\vendor\bin;D:\Users\cangs\AppData\Roaming\cmder\vendor\conemu-maximus5\ConEmu\Scripts;D:\Users\cangs\AppData\Roaming\cmder\vendor\conemu-maximus5;D:\Users\cangs\AppData\Roaming\cmder\vendor\conemu-maximus5\ConEmu;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Program Files\Microsoft VS Code\bin;D:\Program Files (x86)\Tencent\QQ\Bin;D:\Program Files\PremiumSoft\Navicat Premium 12;D:\Users\cangs\AppData\Roaming\ffmpeg\bin;D:\Users\cangs\AppData\Roaming\cmder;D:\Users\cangs\AppData\Roaming\nvm;D:\Program Files\nodejs;D:\Users\cangs\AppData\Local\Programs\Python\Python37\Scripts\;D:\Users\cangs\AppData\Local\Programs\Python\Python37\;C:\Users\cangs\AppData\Local\Microsoft\WindowsApps;D:\Program Files\JetBrains\PhpStorm 2019.2.5\bin;C:\Program Files\Bandizip\;D:\Program Files\JetBrains\PyCharm 2019.2.4\bin;D:\Users\cangs\AppData\Roaming\nvm;D:\Program Files\nodejs;D:\Users\cangs\AppData\Roaming\cmder\vendor\git-for-windows\cmd;D:\Users\cangs\AppData\Roaming\cmder\vendor\git-for-windows\mingw64\bin;D:\Users\cangs\AppData\Roaming\cmder\vendor\git-for-windows\usr\bin;D:\Users\cangs\AppData\Roaming\cmder
9 verbose lifecycle test_webpack#1.0.0~dev: CWD: D:\WWW\test_webpack
10 silly lifecycle test_webpack#1.0.0~dev: Args: [ '/d /s /c', 'webpack' ]
11 silly lifecycle test_webpack#1.0.0~dev: Returned: code: 3221225477 signal: null
12 info lifecycle test_webpack#1.0.0~dev: Failed to exec dev script
13 verbose stack Error: test_webpack#1.0.0 dev: `webpack`
13 verbose stack Exit status 3221225477
13 verbose stack at EventEmitter.<anonymous> (D:\Users\cangs\AppData\Roaming\nvm\v12.0.0\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:196:13)
13 verbose stack at ChildProcess.<anonymous> (D:\Users\cangs\AppData\Roaming\nvm\v12.0.0\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:196:13)
13 verbose stack at maybeClose (internal/child_process.js:1000:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:267:5)
14 verbose pkgid test_webpack#1.0.0
15 verbose cwd D:\WWW\test_webpack
16 verbose Windows_NT 10.0.17763
17 verbose argv "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
18 verbose node v12.0.0
19 verbose npm v6.9.0
20 error code ELIFECYCLE
21 error errno 3221225477
22 error test_webpack#1.0.0 dev: `webpack`
22 error Exit status 3221225477
23 error Failed at the test_webpack#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 [ 3221225477, true ]
But execute node_modules/.bin/webpack is allowed
λ node_modules\.bin\webpack
#
# Fatal error in , line 0
# Check failed: U_SUCCESS(status).
#
#
#
#FailureMessage Object: 000000A3F1AFD030
I can't know the way to solve the error from the error message output. I hope that more experienced people can help me.

Create react app randomly crashes every once in a while on code reload

This is pretty frustrating. I'm developing an app and this started happening a couple weeks ago and I can't nail down the cause. Every once in a while, the app will just crash. It seems to occur more often if I saved my code to trigger a reload, but it can also just randomly crash while navigating through the app in the browser.
As far as I can tell there are no obvious errors, and it happens at a random interval. Sometimes it'll happen twice in a minute, and other times it will go 30 minutes without occurring. Since there's no error that I can see, all I need to do is hit Control+C and re-run npm start, but it's still frustrating to have my workflow interrupted. The only thing I have is this error message in the console:
assert.js:339
throw err;
^
AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
assert(index !== -1)
at PriorityNode.removeChild (C:\Users\Admin\Desktop\project\frontend\node_modules\spdy-transport\lib\spdy-transport\priority.js:74:3)
at PriorityNode.remove (C:\Users\Admin\Desktop\project\frontend\node_modules\spdy-transport\lib\spdy-transport\priority.js:62:15)
at PriorityTree.add (C:\Users\Admin\Desktop\project\frontend\node_modules\spdy-transport\lib\spdy-transport\priority.js:163:23)
at Stream._initPriority (C:\Users\Admin\Desktop\project\frontend\node_modules\spdy-transport\lib\spdy-transport\stream.js:101:25)
at new Stream (C:\Users\Admin\Desktop\project\frontend\node_modules\spdy-transport\lib\spdy-transport\stream.js:76:8)
at Connection._createStream (C:\Users\Admin\Desktop\project\frontend\node_modules\spdy-transport\lib\spdy-transport\connection.js:388:16)
at Connection._handleHeaders (C:\Users\Admin\Desktop\project\frontend\node_modules\spdy-transport\lib\spdy-transport\connection.js:436:21)
at Connection._handleFrame (C:\Users\Admin\Desktop\project\frontend\node_modules\spdy-transport\lib\spdy-transport\connection.js:319:10)
at Parser.<anonymous> (C:\Users\Admin\Desktop\project\frontend\node_modules\spdy-transport\lib\spdy-transport\connection.js:156:10)
at Parser.emit (events.js:198:13)
at addChunk (C:\Users\Admin\Desktop\project\frontend\node_modules\readable-stream\lib\_stream_readable.js:291:12)
at readableAddChunk (C:\Users\Admin\Desktop\project\frontend\node_modules\readable-stream\lib\_stream_readable.js:278:11)
at Parser.Readable.push (C:\Users\Admin\Desktop\project\frontend\node_modules\readable-stream\lib\_stream_readable.js:245:10)
at Parser.Transform.push (C:\Users\Admin\Desktop\project\frontend\node_modules\readable-stream\lib\_stream_transform.js:148:32)
at next (C:\Users\Admin\Desktop\project\frontend\node_modules\spdy-transport\lib\spdy-transport\protocol\base\parser.js:53:12)
at C:\Users\Admin\Desktop\project\frontend\node_modules\spdy-transport\lib\spdy-transport\protocol\http2\parser.js:72:5
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admin\AppData\Roaming\npm-cache\_logs\2019-09-04T04_18_42_331Z-debug.log
and this log:
0 info it worked if it ends with ok
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 'start' ]
2 info using npm#6.9.0
3 info using node#v10.16.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle project#0.1.0~prestart: project#0.1.0
6 info lifecycle project#0.1.0~start: project#0.1.0
7 verbose lifecycle project#0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle project#0.1.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Admin\Desktop\project\frontend\node_modules\.bin;C:\Program Files\PostgreSQL\10\lib;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Users\Admin\AppData\Local\Programs\Python\Python37-32;C:\Users\Admin\.cargo\bin;C:\Program Files\Java\jdk1.8.0_162\bin;C:\Users\Admin\.lein;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Program Files (x86)\Yarn\bin;C:\Program Files\dotnet\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\nodejs\;C:\Program Files\PostgreSQL\10\lib;C:\Users\Admin\.cargo\bin;C:\Users\Admin\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\Admin\AppData\Local\Yarn\bin;C:\Program Files\Java\jdk1.8.0_162\bin;C:\Users\Admin\AppData\Local\GitHubDesktop\bin;C:\Users\Admin\AppData\Roaming\npm
9 verbose lifecycle project#0.1.0~start: CWD: C:\Users\Admin\Desktop\project\frontend
10 silly lifecycle project#0.1.0~start: Args: [ '/d /s /c', 'react-scripts start' ]
11 silly lifecycle project#0.1.0~start: Returned: code: 1 signal: null
12 info lifecycle project#0.1.0~start: Failed to exec start script
13 verbose stack Error: project#0.1.0 start: `react-scripts start`
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:301:16)
13 verbose stack at EventEmitter.emit (events.js:198:13)
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: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 project#0.1.0
15 verbose cwd C:\Users\Admin\Desktop\project\frontend
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" "start"
18 verbose node v10.16.3
19 verbose npm v6.9.0
20 error code ELIFECYCLE
21 error errno 1
22 error project#0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the project#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 ]
Does anyone have any ideas on what the cause might be or how I may further debug it?
You need to upgrade the spdy-transport version that you are using, per this issue: https://github.com/spdy-http2/spdy-transport/issues/62
Sounds similar to the issue here . Looks like it fails trying to open chrome. One suggested solution is to set BROWSER env variable to none.

Permission denied when running NPM module that sets environment variables in Nodejs on Kubuntu 18.04

I am trying to set environment variables on process.env in nodejs using the npm module env-cmd. My system is running Kubuntu 18.04.
I consistently get "permission denied" even when using sudo.
My node and npm versions are the ones from the Ubuntu package manager. So not the latest, but the latest "approved" ones.
I would like to get past this permission denied thing.
I have tried updating env-cmd to the latest package and using the -f switch with the exact same results. I have verified my file path is correct and double checked my code. Which leads me to think this is a "linux thing"
from package.json
"scripts": {
"start": "node src/index.js",
"dev": "env-cmd ./config/dev.env nodemon src/index.js"
},
"devDependencies": {
"env-cmd": "^8.0.2",
"nodemon": "^1.18.9"
}
from dev.env
PORT=3000
from index.js
const port = process.env.PORT;
The expected result is that node runs and variables get set on process.env
Terminal output is
hoo#BadWolf:~/storage/node-task-api v3$ npm run dev
> node-task-manager#1.0.0 dev /home/hoo/storage/node-task-api v3
> sudo env-cmd ./config/dev.env nodemon src/index.js
[sudo] password for hoo:
sudo: env-cmd: command not found
npm ERR! Linux 4.15.0-50-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! node-task-manager#1.0.0 dev: `sudo env-cmd ./config/dev.env nodemon src/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-task-manager#1.0.0 dev script 'sudo env-cmd ./config/dev.env nodemon src/index.js'.
....(details on how to report an issue)
npm ERR! /home/hoo/storage/node-task-api v3/npm-debug.log
debug.log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'dev' ]
2 info using npm#3.5.2
3 info using node#v8.10.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle node-task-manager#1.0.0~predev: node-task-manager#1.0.0
6 silly lifecycle node-task-manager#1.0.0~predev: no script for predev, continuing
7 info lifecycle node-task-manager#1.0.0~dev: node-task-manager#1.0.0
8 verbose lifecycle node-task-manager#1.0.0~dev: unsafe-perm in lifecycle true
9 verbose lifecycle node-task-manager#1.0.0~dev: PATH: /usr/share/npm/bin/node-gyp-bin:/home/hoo/storage/node-task-api v3/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
10 verbose lifecycle node-task-manager#1.0.0~dev: CWD: /home/hoo/storage/node-task-api v3
11 silly lifecycle node-task-manager#1.0.0~dev: Args: [ '-c', 'env-cmd ./config/dev.env nodemon src/index.js' ]
12 silly lifecycle node-task-manager#1.0.0~dev: Returned: code: 126 signal: null
13 info lifecycle node-task-manager#1.0.0~dev: Failed to exec dev script
14 verbose stack Error: node-task-manager#1.0.0 dev: `env-cmd ./config/dev.env nodemon src/index.js`
14 verbose stack Exit status 126
14 verbose stack at EventEmitter.<anonymous> (/usr/share/npm/lib/utils/lifecycle.js:232:16)
14 verbose stack at emitTwo (events.js:126:13)
14 verbose stack at EventEmitter.emit (events.js:214:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/share/npm/lib/utils/spawn.js:24:14)
14 verbose stack at emitTwo (events.js:126:13)
14 verbose stack at ChildProcess.emit (events.js:214:7)
14 verbose stack at maybeClose (internal/child_process.js:925:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
15 verbose pkgid node-task-manager#1.0.0
16 verbose cwd /home/hoo/storage/node-task-api v3
17 error Linux 4.15.0-50-generic
18 error argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
19 error node v8.10.0
20 error npm v3.5.2
21 error code ELIFECYCLE
22 error node-task-manager#1.0.0 dev: `env-cmd ./config/dev.env nodemon src/index.js`
22 error Exit status 126
23 error Failed at the node-task-manager#1.0.0 dev script 'env-cmd ./config/dev.env nodemon src/index.js'.
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 node-task-manager package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error env-cmd ./config/dev.env nodemon src/index.js
....(details on how to report an issue)
24 verbose exit [ 1, true ]
Solved this with some help from Adam Hartleb, a Course Assistant at Udemy. He suggested running it with npx, which worked, after some finagling.
For anyone else having this problem, here is what I did:
I solved this by inspecting the source code for env-cmd, then re-reading the docs.
The problem is that, in Ubuntu 18.04 at least, env-cmd doesn't play well with non-default file locations.
To get it to run, you must have a version of Node that supports npx. If you are in Ubuntu then you have to use a version of node that is not supported by Canonical. The way I solved that was to install NVM and Node 10.15.3
how to install NVM and Node LTS
You will need to use the default file location for your .env file:
./.env
You will need to remove any references to non-default file locations,as their presence will only anger env-cmd. It will have a literal hangup. (it will actually spawn an error called "hangup"). It will also use the word "spawn". I only tell you what I saw.
I changed my "dev" script to
"dev" : "npx env-cmd nodemon src/index.js"
It should work now. May the .env-gods be merciful upon your app.
BACKSTORY: How I got there
Adam's suggestion of "npx env-cmd ./config/dev.env nodemon src/index.js" resulted in:
hoo#BadWolf:~/storage/node-task-api v3$ npx env-cmd ./config/dev.env nodemon src/index.js
(node:19209) UnhandledPromiseRejectionWarning: Error: Unable to locate env file at default location (./.env)
at /home/hoo/storage/node-task-api v3/node_modules/env-cmd/dist/get-env-vars.js:47:19
at Generator.throw (<anonymous>)
at rejected (/home/hoo/storage/node-task-api v3/node_modules/env-cmd/dist/get-env-vars.js:5:65)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:757:11)
at findNodeScript.then.existing (/home/hoo/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/libnpx/index.js:268:14)
(node:19209) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:19209) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I traced the problem back to a few undefined variables in the module code, which I logged to terminal.
hoo#BadWolf:~/storage/node-task-api v3$ npx env-cmd ./config/dev.env nodemon src/index.js
Russ logging from get-env-vars.js 27: getEnvFile({ filePath, fallback }): filePath = undefined
Russ logging from get-env-vars.js 27: getEnvFile({ filePath, fallback }): fallback = undefined
Creating a .env file at ./.env and running the same npx script (with the non-default file argument)
hoo#BadWolf:~/storage/node-task-api v3$ npx env-cmd ./config/dev.env nodemon src/index.js
spawn ./config/dev.env EACCES
Hangup
With the non-default file location removed, to spin up the server with env-cmd run:
npx env-cmd nodemon src/index.js

Error while compiling the project with npm

I am trying to get a project running and when I execute the npm install it installs all the dependencies.
But after that I try to execute npm run compile and it gives me an error.
Here is the log file for better understanding the error.
0 info it worked if it ends with ok
1 verbose cli [ '/Users/roxhens/.nvm/versions/node/v10.13.0/bin/node',
1 verbose cli '/Users/roxhens/.nvm/versions/node/v10.13.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using npm#6.4.1
3 info using node#v10.13.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle jsonforms-tooling-common#0.0.1~prebuild: jsonforms-tooling-common#0.0.1
6 info lifecycle jsonforms-tooling-common#0.0.1~build: jsonforms-tooling-common#0.0.1
7 verbose lifecycle jsonforms-tooling-common#0.0.1~build: unsafe-perm in lifecycle true
8 verbose lifecycle jsonforms-tooling-common#0.0.1~build: PATH: /Users/roxhens/.nvm/versions/node/v10.13.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/roxhens/Desktop/GitHub/jsonforms-tooling/jsonforms-tooling-common/node_modules/.bin:/Users/roxhens/Desktop/GitHub/jsonforms-tooling/jsonforms-tooling-common/node_modules/.bin:/Users/roxhens/Desktop/GitHub/jsonforms-tooling/node_modules/.bin:/Users/roxhens/Desktop/GitHub/node_modules/.bin:/Users/roxhens/Desktop/node_modules/.bin:/Users/roxhens/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/Users/roxhens/.nvm/versions/node/v10.13.0/bin:/Users/roxhens/.nvm/versions/node/v10.13.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/roxhens/Desktop/GitHub/jsonforms-tooling/node_modules/.bin:/Users/roxhens/.nvm/versions/node/v10.13.0/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Python.framework/Versions/3.6/bin
9 verbose lifecycle jsonforms-tooling-common#0.0.1~build: CWD: /Users/roxhens/Desktop/GitHub/jsonforms-tooling/jsonforms-tooling-common
10 silly lifecycle jsonforms-tooling-common#0.0.1~build: Args: [ '-c', 'npm run compile' ]
11 silly lifecycle jsonforms-tooling-common#0.0.1~build: Returned: code: 2 signal: null
12 info lifecycle jsonforms-tooling-common#0.0.1~build: Failed to exec build script
13 verbose stack Error: jsonforms-tooling-common#0.0.1 build: `npm run compile`
13 verbose stack Exit status 2
13 verbose stack at EventEmitter.<anonymous> (/Users/roxhens/.nvm/versions/node/v10.13.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.<anonymous> (/Users/roxhens/.nvm/versions/node/v10.13.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:962:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid jsonforms-tooling-common#0.0.1
15 verbose cwd /Users/roxhens/Desktop/GitHub/jsonforms-tooling/jsonforms-tooling-common
16 verbose Darwin 18.2.0
17 verbose argv "/Users/roxhens/.nvm/versions/node/v10.13.0/bin/node" "/Users/roxhens/.nvm/versions/node/v10.13.0/bin/npm" "run" "build"
18 verbose node v10.13.0
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 2
22 error jsonforms-tooling-common#0.0.1 build: `npm run compile`
22 error Exit status 2
23 error Failed at the jsonforms-tooling-common#0.0.1 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]
This is the package.json in the project root directory.
{
"scripts": {
"lerna": "lerna",
"coveralls": "ts-jest --coverage && cat ./tests/coverage/lcov.info | coveralls",
"postinstall": "npm run lernabootstrap && npm run lernainstall",
"lernainstall": "lerna exec --no-bail --npm-ci-mode -- npm run custominstall",
"lernabootstrap": "lerna bootstrap --npm-ci-mode --ignore-scripts",
"compile": "lerna run build",
"lint": "lerna run lint"
},
"devDependencies": {
"#types/jest": "^23.3.11",
"#types/node": "^10.12.10",
"coveralls": "^3.0.2",
"jest": "^23.6.0",
"lerna": "^3.4.3",
"rimraf": "2.6.3",
"ts-jest": "^23.10.4",
"tslint": "^5.11.0",
"tslint-react": "^3.6.0",
"typescript": "^3.1.6",
"vscode": "^1.1.21"
},
"dependencies": {
"#jsonforms/core": "^2.0.12",
"simple-git": "^1.107.0"
}
}
I guess that you're trying to build the following:
https://github.com/eclipsesource/jsonforms-tooling
When trying to build libraries found on GitHub (or elsewhere), you can look at how they build it on their CI or look at some other scripts. It seems that for this particular lib, their .travis.yml does not contain everything to make it work on all platforms.
I fiddled with it for a bit and running these (rather straightforward) commands from the root folder should solve your problem:
git clone https://github.com/eclipsesource/jsonforms-tooling
cd jsonforms-tooling
npm install
npm run compile
I still cannot find the reason why that error, but I managed to fix it by deleting the files and cloning the repository again.

Categories

Resources