ubuntu 18.04- ember: command not found - javascript

I know this has been addressed before, but I've tried the advice on No command 'ember' found and it hasn't worked for me.
I'm trying to install EmberJs for a techtest and I keep getting 'Command 'ember' not found'. I'm on Ubuntu 18.04, and have checked all my paths as follows.
When I run npm install -g ember-cli it installs and shows:
npm WARN deprecated exists-sync#0.0.4: Please replace with usage of
fs.existsSync
/home/[user]/.npm-global/bin/ember ->
/home/[user]/.npm-global/lib/node_modules/ember-cli/bin/ember
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4
(node_modules/ember-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for
fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current:
{"os":"linux","arch":"x64"})
+ ember-cli#3.5.0
updated 1 package in 14.662s
So I've definitely got it installed.
When I run which npm/ which node I get the following respectively:
/usr/bin/npm
/usr/bin/node
When I run echo $PATH I get:
/home/[user]/npm_global/bin:/usr/local/share/npm/bin:
/usr/local/bin:/usr/local/sbin:~/bin:/usr/share/rvm/gems/ruby-2.3.7/
bin:/usr/share/rvm/gems/ruby-2.3.7#global/bin:/usr/share/rvm/rubies/
ruby-2.3.7/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/
sbin:/bin:/usr/games:/usr/local/games:/usr/bin:/snap/bin:/usr/
share/rvm/bin
Andddd I have these paths in my bashrc:
export PATH="/usr/local/share/npm/bin:/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
and
export PATH="/home/[user]/npm_global/bin:$PATH"
I realise this is a lot of info, I'm new to this so wanted to give as much as I could. Any suggestions very much appreciated, thank you!

The error you are experiencing means that ember is not in the path. It's really irrelevant if you've installed with npm or downloaded the files manually for the purposes of properly setting up your path. When you encounter a PATH issue the solution is quite simple.
Find the executable. find / -name ember if you want to include symlinks, or just find -type f -name ember if you want only the actual location (npm installs will install in their own managed directory and then symlink to the typical location for binary files such as /usr/local/bin on macOS)
Once found, use your shell's properties file like bashrc to append the directory containing the executable to the $PATH variable.
It's as simple as that. Binary files that are found in your $PATH can be executed. Make sure you see the path to ember there, or manually add the full path that you find in step 1 to your $PATH in bashrc with export PATH=$PATH_TO_DIR_WITH_EMBER_BIN:$PATH which concatenates to the existing $PATH variable

Related

npm install: Verfication failed while extracting

READ BEFORE ANSWER: I've already solved this issue. It was a caching issue on the npm servers. Everything works fine after switching to GitHub packages. I've already accepted my own answer.
I have a project, which I want to deploy to elastic beanstalk but sometimes the deploy fails on the npm install script with the following message:
npm ERR! code EINTEGRITY
npm ERR! Verification failed while extracting #my-package#^1.2.0:
npm ERR! Verification failed while extracting #my-package#^1.2.0:
npm ERR! sha512-lQ...HA== integrity checksum failed when using sha512: wanted sha512-lQ...HA== but got sha512-nH...ow==. (4835509 bytes)
It fails even on packages which are severel weeks old.
I’ve tried:
npm cache clean --force
npm cache verify
node_modules is in .npmignore
package-lock.json is in .npmignore
Writing a mail to support#npmjs.com, but they replying always with some helpless default replies without any solution or intention to help.
It fails even on new elastic beanstalk instances.
I have no idea how to solve this problem.
EDIT: I've also tried to delete the npm cache while preinstall script, but it doesn't work either.
EDIT2: My repo has no package-lock.json.
EDIT3: My .npmrc file has the following content
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
unsafe-perm=true
package-lock=false
strict-ssl=false
EDIT4: I think it wasn't clear: It's a private package on the official npm registry. And it doesn't fail always. The current publish process includes several attempts to deploy on aws instance so long as it's succeed.
Have u try to delete package-lock.json?
OR
Try to delete npm and npm-cache folders
THEN
re-run npm install
Not exactly your case, but for those who run into the "integrity checksum failed" error the following might help. But first make sure you understand what's going on. npm tells you that the checksum from https://registry.npm.org doesn't match the one from package-lock.json. Either it changed in the registry, or...
Consider a line from the output:
npm ERR!
sha512-lQ...HA==
integrity checksum failed when using sha512: wanted
sha512-lQ...HA==
but got
sha512-nH...ow==
. (4835509 bytes)
Find the package in package-lock.json by the first two integrity checksums (sha512-lQ...HA==), and put the third one (sha512-nH...ow==) into its "integrity" field.
More on it here.
It seems to be a caching issue at the npm servers. We've switched from npm to GitHub packages, everything works fine there.
It could be that the version of NPM on these instances are out of date. Could you try either: npm install -g npm
Have you made sure that when this is deployed to beanstalk that the package-lock file is not on the instance? - If you have a bad lock file it needs to be deleted and re-generated.
Short of that, would need more information as you seem to have exhausted a lot of options.
This can happen if you request a version that is not available on the registry.
With #my-package#^1.2.0 you're requesting a version between >=1.2.0 and <2.0.0. Could it be that on this registry there is only a version that is older than 1.2.0 or newer than 2.0.0? Npm will install whatever it gets and not raise an error here.
You can check the version you get in an npm install by looking into node_modules/my-package/package.json.
If this is not happening when doing a local npm install, check wether the npm registry Amazon uses is containing your my-package package.
You could try to add the official npm registry to your Beanstalk project to check if it was the Amazon npm registry that did not contain your package. See How to use a private npm registry on Elastic Beanstalk? how to do this.
It seems to be a package-lock.json issue.
As in this answer
If you have not pushed package-lock.json in your repo, it will be generated while running npm install. So it is always better to add package-lock.json in the repo to avoid inconsistent package-lock.json files across local machine and deployment machine.
Could you please try pushing a fresh package-lock.json file to the repo and try?
In my case, as razki alludes to, the version of npm/node on the build server differed significantly from the version on the developer's local computer. Updating to a close enough version got rid of this problem.
For example:
The build server had: npm/6.13.4 node/v12.14.1
The developer has:    npm/6.14.8 node/v14.15.1.
The build server now: npm/6.14.10 node/v14.15.4
It seems the different versions calculate the sha differently for the same package. This is why removing the package-lock.json file can work in this particular situation - at least for a while, until the computer with the different version tries to build the project again.
Basically its concern about npm registery, Some home npm registery has been updated to another url.
You can run below command to see npm registery
npm config get registry
It should be set it
https://registry.npmjs.org/
If its not then run below command
npm config set registry https://registry.npmjs.org/
It will set npm registery. Now you can try again for
npm i
and it will install package successfully.

How could the vue-cli-service crash because of the '#vue/cli-plugin-babel' module, if the node module is there?

Some background:
I started my project with a clone of this repository. Here's an example of the code. After some time, I realized that the vue-cli-service it used appeared to be old. (They even renamed it to '#vue/cli-service'). So, I ran npm update. The code has me use npm run serve to start the service. It's apparently equivalent to npx vue-cli-service serve. When I did that, it couldn't load some bootstrap stuff. I reinstalled bootstrap (npm install bootstrap#version (don't have access to the exact line I used). It then said it couldn't find '#vue/cli-plugin-babel'. I saw it right in the node_modules folder.
I fixed it using this process:
I ran npm update.
It first said that it could not find a font (no longer have the specific details). The error directed to the bootstrap.css file.
I reinstalled bootstrap.
I run npm run serve, and it says "Cannot find module '#vue/cli-plugin-babel'"
I see '#vue/cli-plugin-babel' showing in the node_modules folder
I run npm list --depth=0, and '#vue/cli-plugin-babel' does not show up.
I*’m seeing this
npm cache clean --force alone did not cause the site to resume. It still said “ Cannot find module '#vue/cli-plugin-babel'”.
Following the top SO answer here got my site to work again.
rm -rf node_modules/
npm cache clean (then replaced with npm cache verify on npm's prompt)
npm install (I wonder if it was possible to ignore ‘rm -rf node_modules/’ and just do the last two steps).
I run npm run serve, and the site works again.
After running npm list --depth=0 again, there are no more UNMET DEPENDENCY issues, like with #6.
Also on that SO Q&A, people talked about restructuring (reordering) the package.json file. In the top answer he says that a possible solution is to “Re-structure your package.json. Place all the high-level modules (serves as a dependency for others modules) at the bottom.”. I wonder if that relates to my issue.
My expected vs. actual results:
When I updated it, I actually sort of expected it to break. I got that.
But what I also expected was:
If the node module is there, it will not give me an error.
If I run npm install, all dependencies will be handled automatically.
If npm install doesn't do the trick, then npm cache clean --force should do the trick. (Note: I later learned about npm cache verify).
I got:
The '#vue/cli-plugin-babel' module was there and it gave an error saying it couldn't find it.
(And also 3.) Running npm install and npm install [unmet-dependency] did not work until after 'rm -rf node_modules/' -> `npm verify cache' and THEN -> 'npm install'.
Here are my guesses:
#vue/cli service doesn’t check the folders directly to see if a module exists (75% chance it’s true)
#vue/cli service uses a proxy, something like the packages.json file (but different) to see if a node exists (40%).
#vue/cli service caches commonly used stuff. So, when I ran it again after the update, it didn’t check the new stuff in my folder, it checked its cache. It didn’t line up. (10%).
For everything above, replace #vue/cli service with npm (10%).
Again, my biggest question is "How could the vue-cli-service crash because of the '#vue/cli-plugin-babel' module, if the node module is there?"
And "How did removing the node_modules folder, verifying the cache, and reinstalling with npm cause npx vue-cli-service serve to successfully run my site again (and find #vue/vue-plugin-babel)?".

running lines in my node.js command prompt

I am new to node.js and Github. I was trying to save some work by using command git add -A and the then I saw these lines below and some many of the lines are just running non-stop. I typed ctrl+c to stop it, but anyone knows what are just happened or what did I do wrong??
Thanks
This is because of how git treats the space character.
Find more info here: https://stackoverflow.com/a/1967986/2874959
Thanks #bcorbella for the answer. Just a small precision to be sure you won't do this as a beginner but never add the node_modules into your git project. Create a .gitignore file with at least:
node_modules
Use npm init, npm install <module> --save to create a package.json... then do simply a npm install when you are checking your project.
More info in here https://docs.npmjs.com/getting-started/using-a-package.json
try setting the config core.eol to native and see if you will get the same error, i see no reason why you should be tracking the node_modules/ folder.
> git config --global core.eol native

Angular JS 2 can't be installed, why?

I have tried setting up Angular 2 to experiment with on my VPS. The needed steps are here:
https://angular.io/docs/js/latest/quickstart.html
The first command is successful:
$ npm install -g tsd#^0.6.0
But the second step causes an error:
tsd install angular2 es6-promise rx rx-lite
"/usr/bin/env: node: No such file or directory" is the error I get. I have tried installing this in my project folder as root, but that also didn't had success. Does someone know why I get this error? The command doesn't exist, but why not?
Is there an easier way to install this? I have seen "npm install angular2", but I don't know how that works, that's why I tried the steps
You may need to make a symbolic link to node:
ln -s /usr/bin/nodejs /usr/bin/node
(see https://stackoverflow.com/a/26320915/2033574)

How to compile a node.js module myself

Can someone give me a brief overview of what is involved in compiling a node.js module myself? I need to use mongodb#1.1.3. Unfortunately, npm install mongodb#1.1.3 fails because it has a dependency on bson#0.1.1. bson#0.1.1 uses node install, I am on Xubuntu (Debian), which has changed node to nodejs because of a namespace collision.
Can I just git clone the module into a directory off of ~/workspace/projectname/node_modules? Then modify the offending reference, and voila?
As a quick fix, you can add a link from /usr/bin/nodejs to $HOME/bin/node and make sure that $HOME/bin is first in your path (it should be):
mkdir -p $HOME/bin
ln -s /usr/bin/nodejs $HOME/bin/node
hash -r
echo $PATH
Afterwards, node install should work.

Categories