Closed doitopen closed 7 years ago
same issue here on Linux w Node 7.10.0 and npm 4.2.0
Same issue with Fedora 25 on npm 3.10.10
Same issue in Windows. And on Mint Linux 17.3 with npm 3.10.10
Same issue for me but I have found a solution that worked for me : 1- Delete the globally installed generator : npm uninstall -g generator-angular-2-crud 2- Clone generator-angular-2-crud repo into your npm root repo (to find it : npm -g root) 3- cd generator-angular-2-crud 4- npm install 5- return to your directory where you have defined the dataModel.json file and generate the crud : yo angular-2-crud
6- Enjoy!
that did it, thanks smansri
Worked for me as well, thanks!
I'm going to fix this as soon as possible
1- Delete the globally installed generator : npm uninstall -g generator-angular-2-crud
2- Clone generator-angular-2-crud repo into your npm root repo (to find it : npm -g root)
3- cd generator-angular-2-crud
4- npm install
5- return to your directory where you have defined the dataModel.json file and generate the crud : yo angular-2-crud
I followed above steps, and... On running "yo angular-2-crud", I'm getting "Generator.extend is not a function" error
It seems like yeoman-generator updated it's syntax somehow. Fixed the above by replacing the content of angular-2-crud/generators/app/index.js with the below. I only changed the way of subclassing, all other code is just copy-pasted.
'use strict'; var Generator = require('yeoman-generator'); var chalk = require('chalk'); var yosay = require('yosay'); var fs = require('fs'); var utils = require('../utils');
module.exports = class extends Generator{ prompting() { // Have Yeoman greet the user. this.log(yosay( 'Welcome to the ' + chalk.red('Angular 2 CRUD') + ' generator!' ));
var prompts = [{
type: 'input',
name: 'name',
message: 'Your project name',
default: this.appname
},
{
type: 'input',
name: 'description',
message: 'Your project description',
},
{
type: 'input',
name: 'version',
message: 'Your project version',
default: '0.1.0'
},
{
type: 'input',
name: 'baseurl',
message: 'Server API URL',
default: 'http://localhost:3500'
},
{
type: 'input',
name: 'dataModel',
message: 'Your dataModel relative path',
default: 'dataModel.json'
}];
return this.prompt(prompts).then(function (props) {
// To access props later use this.props.someAnswer;
this.props = props;
}.bind(this));
}
writing() { console.log('after calling readFile');
// try { var models = JSON.parse(fs.readFileSync(this.props.dataModel, 'utf8'));
this.fs.copyTpl(
this.templatePath('_package.json'),
this.destinationPath('package.json'),
{
name: this.props.name,
description: this.props.description,
version: this.props.version,
}
);
this.fs.copyTpl(
this.templatePath('_README.md'),
this.destinationPath('README.md'),
{
name: this.props.name,
description: this.props.description,
version: this.props.version,
dataModel: this.props.dataModel,
models: JSON.stringify(models, null, 2)
}
);
// *
this.fs.copy(
this.templatePath('_tsconfig.json'),
this.destinationPath('tsconfig.json')
);
this.fs.copy(
this.templatePath('_tslint.json'),
this.destinationPath('tslint.json')
);
this.fs.copy(
this.templatePath('_webpack.config.js'),
this.destinationPath('webpack.config.js')
);
//src/*
this.fs.copy(
this.templatePath('src/_global.css'),
this.destinationPath('src/global.css')
);
this.fs.copy(
this.templatePath('src/_polyfills.ts'),
this.destinationPath('src/polyfills.ts')
);
this.fs.copy(
this.templatePath('src/_vendor.ts'),
this.destinationPath('src/vendor.ts')
);
this.fs.copy(
this.templatePath('src/_main.ts'),
this.destinationPath('src/main.ts')
);
this.fs.copyTpl(
this.templatePath('src/_index.html'),
this.destinationPath('src/index.html'),
{
name: this.props.name
}
);
//src/app/*
this.fs.copy(
this.templatePath('src/app/_api.ts'),
this.destinationPath('src/app/api.ts')
);
this.fs.copy(
this.templatePath('src/app/_app.ts'),
this.destinationPath('src/app/app.ts')
);
this.fs.copy(
this.templatePath('src/app/_index.ts'),
this.destinationPath('src/app/index.ts')
);
this.fs.copyTpl(
this.templatePath('src/app/_config.ts'),
this.destinationPath('src/app/config.ts'),
{
baseurl: this.props.baseurl
}
);
var entities = utils.getEntities(models, ['relativeURI']);
this.fs.copyTpl(
this.templatePath('src/app/_routes.ts'),
this.destinationPath('src/app/routes.ts'),
{
entities: entities
}
);
//src/app/store/*
this.fs.copy(
this.templatePath('src/app/store/_helper.ts'),
this.destinationPath('src/app/store/helper.ts')
);
this.fs.copyTpl(
this.templatePath('src/app/store/_index.ts'),
this.destinationPath('src/app/store/index.ts'),
{
entities: entities
}
);
this.fs.copy(
this.templatePath('src/app/containers/_home.ts'),
this.destinationPath('src/app/containers/home.ts')
);
this.fs.copyTpl(
this.templatePath('src/app/store/_state.ts'),
this.destinationPath('src/app/store/state.ts'),
{
entities: entities
}
);
this.fs.copyTpl(
this.templatePath('src/app/containers/_dashboard.ts'),
this.destinationPath('src/app/containers/dashboard.ts'),
{
entities: entities
}
);
this.fs.copyTpl(
this.templatePath('src/app/containers/_index.ts'),
this.destinationPath('src/app/containers/index.ts'),
{
entities: entities
}
);
this.fs.copyTpl(
this.templatePath('src/app/models/_index.ts'),
this.destinationPath('src/app/models/index.ts'),
{
entities: entities
}
);
this.fs.copyTpl(
this.templatePath('src/app/services/_index.ts'),
this.destinationPath('src/app/services/index.ts'),
{
entities: entities
}
);
this.fs.copyTpl(
this.templatePath('src/app/ui/_index.ts'),
this.destinationPath('src/app/ui/index.ts'),
{
entities: entities
}
);
entities.forEach((entity) => {
this.fs.copyTpl(
this.templatePath('src/app/models/_entity.ts'),
this.destinationPath('src/app/models/' + entity.uncapitalize + '.ts'),
{
entity: entity
}
);
this.fs.copyTpl(
this.templatePath('src/app/services/_entity.ts'),
this.destinationPath('src/app/services/' + entity.uncapitalize + '.ts'),
{
entity: entity,
relativeURI: models.relativeURI || ''
}
);
var relations = utils.getRelations(entity, entities);
this.fs.copyTpl(
this.templatePath('src/app/containers/_entity.ts'),
this.destinationPath('src/app/containers/' + entity.uncapitalize + '.ts'),
{
entity: entity,
relations: relations
}
);
this.fs.copyTpl(
this.templatePath('src/app/ui/_entity.ts'),
this.destinationPath('src/app/ui/' + entity.uncapitalize + '/' + entity.uncapitalize +'.ts'),
{
entity: entity,
relations: relations
}
);
this.fs.copyTpl(
this.templatePath('src/app/ui/_entityCreate.ts'),
this.destinationPath('src/app/ui/' + entity.uncapitalize + '/' + entity.uncapitalize +'Create.ts'),
{
entity: entity,
relations: relations
}
);
this.fs.copyTpl(
this.templatePath('src/app/ui/_entityDelete.ts'),
this.destinationPath('src/app/ui/' + entity.uncapitalize + '/' + entity.uncapitalize +'Delete.ts'),
{
entity: entity,
relations: relations
}
);
this.fs.copyTpl(
this.templatePath('src/app/ui/_entityEdit.ts'),
this.destinationPath('src/app/ui/' + entity.uncapitalize + '/' + entity.uncapitalize +'Edit.ts'),
{
entity: entity,
relations: relations
}
);
})
/*}
catch (errr) {
console.log('Error: ' + errr);
}*/
}
install() { this.installDependencies(); } }
Thanks @augustbering for the fix. I'm still waiting for a 'yo' response about why this is happening with the angular-2-crud generator.
I'm going to use the @smansri solution to update the readme.md
Hi there!
I still have this issue =(
did clone into npm_modules global folder, install the project there gives me a lot of errors:.
> fsevents@1.1.3 install /Users/mariohmol/.npm-packages/lib/node_modules/generator-angular-2-crud/node_modules/fsevents
> node install
node-pre-gyp ERR! Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.1.3/fse-v1.1.3-node-v72-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for fsevents@1.1.3 and node@12.2.0 (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.1.3/fse-v1.1.3-node-v72-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for fsevents@1.1.3 and node@12.2.0 (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
Then I try to use the yo angular-2-crud
and says that dont find.. can u help me on that?
Hello, On the following config on windows 10 : node v6.10.3 npm -v 4.5.0
I follow the intallation instructions, the generator is installed but yo cannot find it.
NODE_PATH id setup, I have no problem with other generators.
I noticed there is no "app" folder in the generator-angular-2-crud node module
` yo angular-2-crud Error angular-2-crud
You don’t seem to have a generator with the name “angular-2-crud” installed. But help is on the way:
You can see available generators via npm search yeoman-generator or via http://yeoman.io/generators/. Install them with npm install generator-angular-2-crud.
To see all your installed generators run yo without any arguments. Adding the --help option will also show subgenerators.
If yo cannot find the generator, run yo doctor to troubleshoot your system. `