running babel-node commands on AWS elastic Beanstalk? - javascript

Im trying to deploy an nodejs app to eb, all my code is using the new js features.
On my package.json I have start command:
scripts : {
start: "babel-node bin/start.js"
}
this works fine on my localhost, when I deploy the app to EB, i get the error on the logs saying:
sh: babel-node: command not found
Can i run the babel-node command on a cloud server, or shall i compile my code before deployment.

Include babel-cli as a dependency in your package.json
You can do this by doing npm i babel-cli
However
That solves your problem but babel-node is not recommended for production use as stated in the usage docs

Related

git push heroku master Remote failed

This is my error image getting on heroku logs --tail
above is a given image of my errors. When I am trying to deploy my nodejs app Getting error on git push Heroku master .
.
.
.
Remote failed
working properly on local server. I am beginner please help my git id is cosmos-dx and there is a git repo of name Webdictionary
After reading through the nodemon docs, and taking the fact that you stated you are new, I think I know what is happening.
In the nodemon docs it gives you two ways to install, one is globally npm install -g nodemon and the other is to install it in the dev dependencies npm install --save-dev nodemon. Either of these options would make nodemon not be present if the build to heroku uses npm install --only=production. I assume they do that.
In your package.json file, change the npm start script to this:
"start": "node ser1.js"
As nodemon is not present in the heroku built application, your current start script will fail. If you want to continue using nodemon for local development you can add a new script:
"dev": "nodemon ser1.js"
From there to run your application, with nodemon, on your local machine you would run npm run dev

HOW can i run "npm run dev" in cpanel i working on laravel project

I working on laravel project and I need run this command in the terminal in Cpanel npm run dev
Do have installed it? If so, try to find /node_modules/npm/bin/npm-cli.js and run it with full path starting root.
Like:/usr/lib/node_modules/npm/bin/npm-cli.js -v

baseUrl not being found when running cypress tests through Travis CI

I am trying to run my cypress tests when building a project through Travis CI. I am installing cypress fine, however, I was then getting the following error:
I have looked online and in cypress official documentation and the method that they recommend fixing this issue by adding the following into my package.json:
"test:ci": "start-server-and-test http://localhost:3000 cy:run"
cy:run in this case being cypress run. However, when I run this, it does build the server however it then does not seem to run the tests afterwards. It just freezes on the build.
I then call this script within my travis.yml file as shown:
- npm run test:ci
I also have the following as my before_install and install object:
before_install:
- npm i -g npm#5
- npm i -g firebase-tools
- npm i -g #angular/cli
- npm cache verify
install:
- npm i
- npm ci
To clarify - the desired results is that when running Cypress through Travis, the local server (my baseUrl) is run and then the tests are carried out.
Use "baseUrl":"http://host.docker.internal:3000" in your cypress.json

Error when attempting to deploy Next.js app to Zeit cloud, running in dev mode

I am unable to deploy my Next.js App to Zeit using the now command.
I tried uninstalling sass reinstalling npm i node-sass as well as npm i node-sass --force. None of this worked. I get the following error.
Node Sass could not find a binding for your current environment: OS X 64-bit with Node XX.X.X
The application must deploy or at least run in dev mode 'now dev'. It runs fine in my local dev environment when I run 'npm run dev'.
How I fixed the problem was, I wrote a bash script that does the following steps.
# Delete build files
sudo rm -rd .next
# Delete node modules
sudo rm -rd node_modules
# Then I ran this without installing the node_modules again
now dev
When I let the zeit builder install the node_modules the test deployment worked like a charm.

"npm-run-all" Is Not Recognized As an Internal or External Command

I installed npm-run-all and also configured the environment variable (which may or may not be not required) on my Windows machine but am getting an error:
'npm-run-all' is not recognized as an internal or external command,
operable program or batch file
I am trying to build my current project with npm run build which includes the script where the error is thrown:
npm-run-all -p build-css build-webpack
Do I have to do any additional things to make it run?
Make sure the npm-run-all is in your package.json devDependencies.
If npm-run-all is present in your package.json, run npm i
If not present install it, run: npm i npm-run-all -D
If error is still present, follow these steps:
Remove node_modules folder: run rm -rf node_modules
Install all dependecies: run npm i
Hope this helps!
You may just need to run the following command first (from the directory with the package.json file)
npm install
Please do that like this.
npm i npm-run-all -g
And then this issue will be fixed.
You have a couple of options here, besides installing npm-run-all as a global package as suggested by #Vaibhav in the comments:
1) Create an NPM script
The package.json file has a scripts section which can used to define shortcuts for anything you need to run while you're working on your app. There are some pre-defined scripts, like run or test than can be executed with simply npm start/npm test or you can define anything you like and then run it with npm run my-script-name. You could try:
{
"scripts": {
"start": "npm-run-all -p build-css build-webpack"
}
}
Any NPM module referenced here "just works" (i.e. the path to the executable is resolved under the hood by NPM)
2) NPX
In newer versions of NPM (i.e. >= 5.2 or so), the "NPX" executable is provided. This has a similar effect to running commands inside an NPM script. You would run:
npx npm-run-all -p build-css build-webpack
Again, the path would be automatically resolved.
If you have an older NPM install, you can also install it separately:
npm install -g npx
npm install -g npm-run-all
Works for me.
Double check if npm-run-all is in your package.json devDependencies.
I had same problem while using code editor Brackets.
To resolve the error, I did the following steps.
Add nodejs new system variable to your PC under Control Panel -> System -> Advanced System Settings
;C:\Program Files\nodejs\
After that, re-run command:
npm
I don't know if this would help anyone, but I got this error because I was doing nodemon server.js instead of nodemon server/server.js. I wasn't in the right folder!
Did you reopen the terminal after you installed node?
If you have installed npm with the current terminal window open. Your terminal window will not have loaded the latest path settings (with npm location) to find the npm application to run the command. In this case try below steps .
Try closing the current terminal session.
Reopen a new session.
Try the command again ( will pick up the new path settings with npm installed)
This worked for me.
npm audit fix --force
Also you can try downgrading your autoprefixer, seems version 10.0.0 doesn't work well with postcss
npm i autoprefixer#9.8.6

Categories

Resources