You have to be inside an ember-cli project in order to use the serve command - ember-cli

I done a git clone of ember-cli, and then done this:
cd ember-cli
npm link ember-cli
ember server
but get
You have to be inside an ember-cli project in order to use the serve command.
any ideas?
EDIT___________________________________________
I got round this by just reinstalling it again.

While you are inside the ember-cli directory, you are not inside of an actual ember-cli project which is why ember server does not work. I'm not sure what you are trying to do, but if you are trying to create an ember-cli project you can do these commands outside of that ember-cli directory:
ember new foo
cd foo
npm link ember-cli
ember server

If you use app name as ember-cli, emberCli, you will get this error. These words are reserved words.

Related

TNS command not found after installing NativeScript

I updated NPM and Node before installing NativeScript, without errors I might add, but when I attempt to create a new project using tns create MyProjectName, I get the error tns command not found.
After much reading, I'm getting the feeling it has something to do with my PATH.
This is what is outputted in terminal during the NativeScript install regarding TNS:
sudo npm install -g nativescript --unsafe-perm
/Users/martingeldart/.npm-global/bin/tns -> /Users/martingeldart/.npm-global/lib/node_modules/nativescript/bin/tns
/Users/martingeldart/.npm-global/bin/nativescript -> /Users/martingeldart/.npm-global/lib/node_modules/nativescript/bin/tns
...
If I run echo $PATH, this is what outputs:
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/bin/lib/node_modules/nativescript/bin
Which looks really odd to me but I'm no command line expert by any means. In fact, I'm incredibly inexperienced with the whole command line system.
Why am I not able to access the tns command? What is going on with that PATH I echoed?
MacOSX
Between version of npm the location of the global package moved location in the OS. Since the installation has moved the terminal does not know where to find the command. The PATH variable is used to tell the terminal where all the command may be located. In this case this seems a standard.
Now the best way to access command from an installed package is to use npx which is included by default with the new installation of npm.
https://docs.npmjs.com/downloading-and-installing-packages-globally
npx tns
# In your case
npx tns create MyProjectName
There 2 other ways to resolve this.
Either your global package folder is not set up correctly.
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
Add the bin folder where nativescript was install to your path manually (usually in .bash_profile), open a new terminal.
I use nativescript for various project and I have a suggestion for package management. Usually I avoid installing global package because in case of multiple project there may be conflict between version if some project are updated and other not.
I usually create a folder with the version I am installing. Go to the folder, npm init and install locally the package.
mkdir nativescript-project-6-0
cd nativescript-project-6-0
npm init
npm i --save nativescript
Now I have a fix version to work with and can create other project with the same version even if I have other project with newer version of the tool or lib. Now in nativescript-project-6-0 I create my project.
npx tns create MyProjectName
This should create a folder nativescript-project-6-0/MyProjectName. All set and ready to go. Remember that is is always a good idea to use npx in this case since we want to use the local package.

Using an NPM module from Ionic

I am using ionic 1.3.1 and I want to use the npm phone module here to validate phone numbers on the client side.
In looking around on how to use the npm module, I followed instructions in this SO post (last answer at the bottom) and copied the phone directory from npm_modules to www/lib. I then included the lib/phone/lib/index.js file in my index.html.
When I bring up the page with ionic serve I get the error "module not found".
I see solutions for using npm in Ionic v2 but am not ready to move to v2 yet. I also see some answers pointing towards using Browserify but I am trying to avoid having to use new tools if I don't need to - feels like there must be a simple way to use an npm module inside ionic.
Thanks for any pointers to help resolve.
Sanjay
Since I couldn't figure this out I just created an Angular service from the code in the index.js file for the npm phone module.

Deploying Mean stack webapp on AWS

I have created a webapp based on the the Mean Stack( MongoDB, Express, AngularJS, NodeJS). I had followed this tutorial on setting up AWS: https://scotch.io/tutorials/deploying-a-mean-app-to-amazon-ec2-part-1
I got to the point where they started their server.js file by just calling node server.js. I do not have a server.js though. In webstorm I run grunt serve and it launches everything. On aws I run grunt serve and it just says cannot find bower components. I also try to run bower install and it fails saying I do not have permission but when I run sudo bower install it says bower cannot be run with sudo.
I am not sure how to solve this issue. Should I figure out how to use a server.js?
Any help wold be greatly appreciated
You can use npm start instead of node server.js, if you have initialized the app using npm init.

Why does Yeoman generator not work when installed through npm?

Code
GitHub version: https://github.com/trevordmiller/generator-code-deck
npm version: https://www.npmjs.org/package/generator-code-deck
Background
I have built a Yeoman generator which is working perfectly locally (using npm link after cloning the repo from GitHub). However, when I npm publish the generator to npm and install it via npm install -g generator-code-deck, running the generator throws no such file or directory and cannot find module errors:
These errors don't make sense to me, because 1. the files and folders are obviously there (as shown by the screenshot doodles) and 2. the generator is working via a symbolic link to the local repo; why should the npm package be any different?
I have been searching online to find an answer but I can't find anything. Does anyone know why these errors are happening when trying to install via npm, but not via a symbolic link? Does anyone know how to fix this so that I can release the official npm version of the Yeoman generator? Any help would be much appreciated!
Chances are you're not publishing all files to npm.
This can be caused by a .npmignore file or by the files key of your package.json.

Does not make sense that I have to have files before import

How do I import an external package from scratch?
I've written a library package in Go and testing to distribute through github. I am following http://golang.org/doc/code.html and using mac but getting error message
cmd I put is following.
$ mkdir $HOME/go
$ export GOPATH=$HOME/go
$ export PATH=$PATH:$GOPATH/bin
$ mkdir -p $GOPATH/src/github.com/user
$ mkdir $GOPATH/src/github.com/user/project
Then I put
$ go get github.com/user/project
Still errors with go install
can't load package: package github.com/golingorg/goling: no Go source files in /Users/user_name/go/src/github.com/user/project
I do not understand why we need files to import an external package in Go. External package means that I get something and create files from the external package.
My question is how I import an external package from scratch. Most of documents just say something like
go get github.com/yasushi-saito/fifo_queue
this gives me "$GOPATH not set."
I am getting frustrated setting up the environment for "go get" to work, as a beginner. Thanks a lot in advance.
Summary
How do I import an external package from scratch?
Go is a static type language thus it needs to resolve any reference to external package at compile time. The "go" tool expects the source of external packages in locally accessible path thus you need to use "go get" to download them.
From what you described, you probably did not set the GOPATH. Use ECHO $GOPATH to check if it is set correctly.
For my GO project, I normally use GOPATH as workspace, similar to virtualenv in Python or rbenv/rvm in Ruby. Let say my project "myproject" has root at /projects/myproject, my source file will be located at /projects/myproject/src/myproject and there is an import of "github.com/user/project", then
> cd /projects/myproject
> export GOPATH=`pwd` # or export GOPATH=/projects/myproject
> go get github.com/user/project
After "go get" command, the source of "github.com/user/project" will be downloaded to /projects/myproject/src/github.com/user/project.
When you use "go build" or "go install" then, it will compile as the external packages is in the $GOPATH/src folder.
If you install Go in the default folder, you need to include Go installed bin folder in the PATH environment variable. After that GOPATH is the other environment variable you need for "go" tool to work.
That's how I done it:
1. Setup your workspace first
mkdir $HOME/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
2. Create the project
mkdir -p $GOPATH/src/github.com/user
mkdir $GOPATH/src/github.com/user/hello
touch $GOPATH/src/github.com/user/hello/hello.go
3. Install it
go install github.com/user/hello
4. Run it
cd $GOPATH/bin
./hello
I used the following vagrant image: https://github.com/dcoxall/vagrant-golang
From the help output for go get, it says:
By default, get uses the network to check out missing packages but does not use it to look for updates to existing packages.
When you created the $GOPATH/src/github.com/user/project directory prior to running go get, it assumed that the package had already been downloaded so skipped to the step of trying to build and install the package. That failed because the directory contained no Go source files.
So the simple fix is to not create the folder associated with the package you are trying to download: go get will do that for you.