Error running npm Script when starting Docker Container - node.js

In my DockerFile i have this setup as my command.
CMD config/startserver.sh
Having problem getting npm run build to work. I have no problem running npm run build when i go into the conatiner and run docekr exec npm run build manually but for some reason running it inside the .sh causes a problem. Any ideas as to why running npm run build inside an .sh could be causing a problem.
npm run build
pm2 start server.js -f -- 5000
pm2 start server.js -f -- 5001
pm2 start server.js -f -- 5002
pm2 start server.js -f -- 5003
pm2 start server.js -f -- 5004
nginx -g "daemon off;"
wait
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build\r' ]
2 info using npm#6.13.4
3 info using node#v10.19.0
4 verbose config Skipping project config: /home/lgd/.npmrc. (matches userconfig)
5 verbose stack Error: missing script: build
5 verbose stack
5 verbose stack Did you mean this?
5 verbose stack build
5 verbose stack at run (/usr/lib/node_modules/npm/lib/run-script.js:155:19)
5 verbose stack at /usr/lib/node_modules/npm/lib/run-script.js:63:5
5 verbose stack at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:116:5
5 verbose stack at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:436:5
5 verbose stack at checkBinReferences_ (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:391:45)
5 verbose stack at final (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:434:3)
5 verbose stack at then (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:161:5)
5 verbose stack at ReadFileContext.<anonymous> (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:350:20)
5 verbose stack at ReadFileContext.callback (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:115:16)
5 verbose stack at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:237:13)
6 verbose cwd /home/lgd
7 verbose Linux 4.19.76-linuxkit
8 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build\r"
9 verbose node v10.19.0
10 verbose npm v6.13.4
11 error missing script: build
11 error
11 error Did you mean this?
11 error build
12 verbose exit [ 1, true ]

Had to revert back to calling script in Docker because i was getting permission errors on my Server when i pushed my container.
I think David was right and i just needed to fix my line endings.
I ended up changing
CMD config/startserver.sh
to
CMD [ "npm", "run", "start-production" ]
And added to my package.json scripts
"start-production": "npm run build && config/startserver.sh"

Related

sh: 1: rimraf: Permission denied issue on live server

Thanks for looking at my issue.
Basically I am facing problem with making build on production dedicated server.
I have executed "npm run build" command and I have received the
the issue
sh: 1: rimraf: Permission denied issue on live server
I am not sure how exactly we should solve it.
My error logs are as follow below.
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
2 info using npm#6.10.2
3 info using node#v9.11.2
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle #~prebuild: #
6 info lifecycle #~build: #
7 verbose lifecycle #~build: unsafe-perm in lifecycle true
8 verbose lifecycle #~build: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/www/html/basepath/moneytransfer/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
9 verbose lifecycle #~build: CWD: /var/www/html/basepath/moneytransfer
10 silly lifecycle #~build: Args: [ '-c',
10 silly lifecycle 'npm run clean && webpack --mode development --progress' ]
11 silly lifecycle #~build: Returned: code: 126 signal: null
12 info lifecycle #~build: Failed to exec build script
13 verbose stack Error: # build: `npm run clean && webpack --mode development --progress`
13 verbose stack Exit status 126
13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:326:16)
13 verbose stack at EventEmitter.emit (events.js:180:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:180:13)
13 verbose stack at maybeClose (internal/child_process.js:936:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid #
15 verbose cwd /var/www/html/basepath/moneytransfer
16 verbose Linux 4.15.0-29-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
18 verbose node v9.11.2
19 verbose npm v6.10.2
20 error code ELIFECYCLE
21 error errno 126
22 error # build: `npm run clean && webpack --mode development --progress`
22 error Exit status 126
23 error Failed at the # build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 126, true ]
npm i rimraf
worked for me because I was not in wifi environment. I had a similar error trace (after porting a project with node_modules from windows to mac)
I tried so many solution but nothing worked.But finally removed node_modules folder and executed "npm install" which means re-installation of node modules.And Everything seems working fine now.
Deleting the node_modules folder seemed to do the trick whenever I was running into such problems!
It is probably caused by different rules related to different file systems; e.g. just different systems or even different operating systems.

Node.js npm run dev throws missing module error

I'm running ubuntu on Virtual Machine on a windows computer; I have node.js and npm installed globally (node version 10.6.0; npm version 6.4.1). I cloned a React app from our internal bitbucket repo, checked out to a branch and created a new branch from that; the app is supposed to run by 'npm run dev' but when I try to run it, I get the following error:
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module 'braces'
When I install module 'braces', and try 'npm run dev' it gives missing module of some other module and so on. I was told by one of the developers that I need to be running npm locally and not globally (which is how I have it in my case); I tried uninstalling node.js and npm but the system won't uninstall it. Do i need to do the uninstall from root (by doing sudo -i, going to root and uninstalling)? Also, I need node.js version 10.6.0 and npm version 6.4.1 which is needed to run my other node.js/graphQL APIs - how do I make sure that I install those exact versions, after uninstalling node.js and npm from root?
Following is debug info from debug log:
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'dev'
]
2 info using npm#6.4.1
3 info using node#v10.6.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle abcms#1.0.2~predev: abcms#1.0.2
6 info lifecycle abcms#1.0.2~dev: abcms#1.0.2
7 verbose lifecycle abcms#1.0.2~dev: unsafe-perm in lifecycle true
8 verbose lifecycle abcms#1.0.2~dev: PATH:
/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-
bin:/home/usname123/Documents/DEV/uppperFolder/
abcms/node_modules/.bin:/home/rv7
94a/bin:/usr/local/bin:/usr/bin:/usr/bin/js:/home/usname123/.local/
bin:/home/usn
ame123/bin:/home/usname123/.local/bin:/var/opt/SoapUI-
5.2.1/bin:/var/opt/java/jdk1.8.0_77/bin:/usr/
local/sbin:/usr/local/bin:/usr/sbin
:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle abcms#1.0.2~dev: CWD:
/home/rv794a/Documents/DEV/upperFolder/abcms
10 silly lifecycle abcms#1.0.2~dev: Args:
[ '-c', 'webpack-dev-server --
mode development --open' ]
11 silly lifecycle abcms#1.0.2~dev: Returned: code: 1 signal: null
12 info lifecycle abcms#1.0.2~dev: Failed to exec dev script
13 verbose stack Error: abcms#1.0.2 dev: `webpack-dev-server --mode
development --open`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous>
(/usr/local/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>
(/usr/local/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 abcms#1.0.2
15 verbose cwd /home/usname123/Documents/DEV/upperFolder/abcms
16 verbose Linux 4.4.0-159-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
18 verbose node v10.6.0
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error abcms#1.0.2 dev: `webpack-dev-server --mode development --open`
22 error Exit status 1
23 error Failed at the abcms#1.0.2 dev script.
23 error This is probably not a problem with npm. There is likely
additional logging output above.
24 verbose exit [ 1, true ]

npm ERR! missing script: build:universal

I am trying to run my Angular application on the server side and I am facing these errors:
npm ERR! missing script: build:universal
npm ERR! A complete log of this run can be found in: npm ERR!
/home/training/.npm/_logs/2018-10-03T11_50_40_593Z-debug.log
I used the official Angular application for doing this
https://angular.io/guide/universal
The universal build is causing errors shown below:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'run',
1 verbose cli 'build:universal' ]
2 info using npm#6.2.0
3 info using node#v10.8.0
4 verbose stack Error: missing script: build:universal
4 verbose stack at run (/usr/local/lib/node_modules/npm/lib/run-script.js:155:19)
4 verbose stack at /usr/local/lib/node_modules/npm/lib/run-script.js:63:5
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:5
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:418:5
4 verbose stack at checkBinReferences_ (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:373:45)
4 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:416:3)
4 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:160:5)
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:280:12
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
5 verbose cwd /home/training/Desktop/vishnu/TemplateAppv6
6 verbose Linux 4.4.0-134-generic
7 verbose argv "/usr/bin/nodejs" "/usr/local/bin/npm" "run" "build:universal"
8 verbose node v10.8.0
9 verbose npm v6.2.0
10 error missing script: build:universal
11 verbose exit [ 1, true ]
As implied in my comment, you may have forgotten to add the build-script to your project:
From the universal docs
Build and run with universal: Now that you've created the TypeScript
and Webpack config files and configured the Angular CLI, you can build
and run the Universal application.
First add the build and serve commands to the scripts section of the
package.json:
"scripts": {
...
"build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
"serve:ssr": "node dist/server",
"build:client-and-server-bundles": "ng build --prod && ng run angular.io-example:server",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors"
...
}
So check you package.json and try the build again..

Electron works, a bit...?

I installed the latest version of node and electron and tried out the samples. They work when I enter "npm start".
However: when I try to make an app in another folder and launch it, I get this npm-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm#3.10.10
3 info using node#v6.11.2
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle proton-template-app#1.0.0~prestart: proton-template-app#1.0.0
6 silly lifecycle proton-template-app#1.0.0~prestart: no script for prestart, continuing
7 info lifecycle proton-template-app#1.0.0~start: proton-template-app#1.0.0
8 verbose lifecycle proton-template-app#1.0.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle proton-template-app#1.0.0~start: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/home/erik/Projects/Electron/tmp2/node_modules/.bin:/home/erik/bin:/home/erik/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
10 verbose lifecycle proton-template-app#1.0.0~start: CWD: /home/erik/Projects/Electron/tmp2
11 silly lifecycle proton-template-app#1.0.0~start: Args: [ '-c', 'electron .' ]
12 info lifecycle proton-template-app#1.0.0~start: Failed to exec start script
13 verbose stack Error: proton-template-app#1.0.0 start: `electron .`
13 verbose stack spawn ENOENT
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:33:16)
13 verbose stack at emitTwo (events.js:106:13)
13 verbose stack at ChildProcess.emit (events.js:191:7)
13 verbose stack at maybeClose (internal/child_process.js:891:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
14 verbose pkgid proton-template-app#1.0.0
15 verbose cwd /home/erik/Projects/Electron/tmp2
16 error Linux 4.4.0-79-generic
17 error argv "/usr/bin/node" "/usr/bin/npm" "start"
18 error node v6.11.2
19 error npm v3.10.10
20 error file sh
21 error code ELIFECYCLE
22 error errno ENOENT
23 error syscall spawn
24 error proton-template-app#1.0.0 start: `electron .`
24 error spawn ENOENT
25 error Failed at the proton-template-app#1.0.0 start script 'electron .'.
25 error Make sure you have the latest version of node.js and npm installed.
25 error If you do, this is most likely a problem with the proton-template-app package,
25 error not with npm itself.
25 error Tell the author that this fails on your system:
25 error electron .
25 error You can get information on how to open an issue for this project with:
25 error npm bugs proton-template-app
25 error Or if that isn't available, you can get their info via:
25 error npm owner ls proton-template-app
25 error There is likely additional logging output above.
26 verbose exit [ 1, true ]
I'm afraid my install wasn't 100% ok, what should I do? Install again? How do I uninstall correctly? - I'm stuck, please help ;-)
The technicality is in your package.json, and your installation of Electron, but this is regardless of having it saved under dependencies.
If your start script in package.json calls electron ., you will need to install Electron globally with npm install electron -g. This goes for all commands where you use the name, much like mocha and cordova create. Just some examples.
To use it locally (non-globally) and only inside the project, you can just call npm install electron (which you may have done), but your startscript will have to point to the electron file inside the local node_modules folder. Usually the path is node_modules/.bin/electron.cmd, and your start script can look like node_modules/.bin/electron .
If you ever come across this problem inside an IDE, you should set electron.cmd in .bin as your executable, then . as your arguments.
Make sure you have installed electron globally, to do so run the following command:
npm install -g electron
Once you have installed it try running electron in your command prompt it should open a demo app.
To uninstall electron from the global scope:
npm uninstall -g electron

Kurento OneToMany With Rooms

I look at this link
https://github.com/BitOfUniverse/kurento-one2many-with-rooms/issues/1
and decided to run on my local machine via VMvare on Ubuntu Server 14.04 TLS
Before start to run this,
I install KMS 6 on ubuntu via this referance page.
doc-kurento.readthedocs.io/en/stable/installation_guide.html#migrating-from-kms-v5-to-v6
After KMS install, I follow the this link at below as referance
doc-kurento.readthedocs.io/en/stable/tutorials/node/tutorial-one2many.html
My installation step for this link a little different
Here is the my installation steps:
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
sudo npm install -g bower
After this step
I follow these
git clone https://github.com/BitOfUniverse/kurento-one2many-with-rooms.git
cd kurento-tutorial-node/kurento-one2many-call
git checkout 6.6.0
npm install
At there I used your git adress: git clone https://github.com/BitOfUniverse/kurento-one2many-with-rooms.git
Until these steps everthing looks fine. But when I run this command
npm start
I get the following error on log file
0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node',
'/usr/bin/npm', 'start' ] 2 info using npm#2.15.1 3 info using
node#v0.10.48 4 verbose node symlink /usr/bin/node 5 verbose
run-script [ 'prestart', 'start', 'poststart' ] 6 info prestart
kurento-one2many-call#6.2.2-dev 7 info start
kurento-one2many-call#6.2.2-dev 8 verbose unsafe-perm in lifecycle
true 9 info kurento-one2many-call#6.2.2-dev Failed to exec start
script 10 verbose stack Error: kurento-one2many-call#6.2.2-dev start:
node server.js 10 verbose stack Exit status 8 10 verbose stack at
EventEmitter.
(/usr/lib/node_modules/npm/lib/utils/lifecycle.js:217:16) 10 verbose
stack at EventEmitter.emit (events.js:98:17) 10 verbose stack at
ChildProcess. (/usr/lib/node_modules/npm/lib/utils/spawn.js:24:14) 10
verbose stack at ChildProcess.emit (events.js:98:17) 10 verbose stack
at maybeClose (child_process.js:766:16) 10 verbose stack at
Process.ChildProcess._handle.onexit (child_process.js:833:5) 11
verbose pkgid kurento-one2many-call#6.2.2-dev 12 verbose cwd
/home/can/kurento-one2many-with-rooms 13 error Linux 4.4.0-31-generic
14 error argv "/usr/bin/node" "/usr/bin/npm" "start" 15 error node
v0.10.48 16 error npm v2.15.1 17 error code ELIFECYCLE 18 error
kurento-one2many-call#6.2.2-dev start: node server.js 18 error Exit
status 8 19 error Failed at the kurento-one2many-call#6.2.2-dev start
script 'node server.js'. 19 error This is most likely a problem with
the kurento-one2many-call package, 19 error not with npm itself. 19
error Tell the author that this fails on your system: 19 error node
server.js 19 error You can get information on how to open an issue for
this project with: 19 error npm bugs kurento-one2many-call 19 error Or
if that isn't available, you can get their info via: 19 error 19 error
npm owner ls kurento-one2many-call 19 error There is likely additional
logging output above. 20 verbose exit [ 1, true ]
My question is that, What Am I wrong? When I try to run example on Kurento, there isn't any error. But at there I get these error.
Also, I try to install socket.Io and etc. when I get error, but not solve my problem.
I found on the internet that 8080 port problem and kill apps on this port on cmd but still I have error.
What can I do? If you help me, I will be very happy.
Thaks a lot of your answer, have a nice and hapy day :) :) :)
Best Rigards
There is a postinstall script you need to run after building the project (npm run postinstall). On lines 34 & 35 of project readFileSync uses relative path which doesn't work. You can fix that with path.join or simply hardcode full path. Also file names used for SSL keys are different from the ones on github and should be changed.
After all you may build the project but it doesn't work. Here is a refined fork.

Resources