nestjs / javascript-starter Goto Github PK
View Code? Open in Web Editor NEWNest framework JavaScript (ES6, ES7, ES8) + Babel starter 🍰
Home Page: https://nestjs.com/
Nest framework JavaScript (ES6, ES7, ES8) + Babel starter 🍰
Home Page: https://nestjs.com/
I've started a new Node.js project and followed the passport authentication tutorial until:
https://docs.nestjs.com/techniques/authentication#jwt-functionality
Applications should start.
My jsconfig.json
file (I'v changed to esnext
as suggested by nestjs/passport#27:
{
"compilerOptions": {
"target": "esnext",
"experimentalDecorators": true
},
"exclude": [
"node_modules"
]
}
Nest version: 6.7.2
For Tooling issues:
- Node version: v12.6.0
- Platform: Mac
Others:
I've also edited local.strategy.js
, i've switched the super();
and this.authService = authService;
lines as I was getting an error:
TypeError: Cannot set property 'authService' of undefined
local.strategy.js
import { Strategy } from 'passport-local';
import { PassportStrategy } from '@nestjs/passport';
import { Injectable, UnauthorizedException, Dependencies } from '@nestjs/common';
import { AuthService } from './auth.service';
@Injectable()
@Dependencies(AuthService)
export class LocalStrategy extends PassportStrategy(Strategy) {
constructor(authService) {
super();
this.authService = authService;
}
async validate(username, password) {
const user = await this.authService.validateUser(username, password);
if (!user) {
throw new UnauthorizedException();
}
return user;
}
}
Hi, wanted to try the framework and the project does not run since its missing modules after npm install
. I only cloned the repo and run both npm install
and npm run start
.
Error stack:
babel-node index.js
internal/modules/cjs/loader.js:438
throw e;
^
Error: Cannot find module 'C:\Users\Enzo\Desktop\hipercore-nest\node_modules\@babel\compat-data\data\corejs3-shipped-proposals'
at createEsmNotFoundErr (internal/modules/cjs/loader.js:907:15)
at finalizeEsmResolution (internal/modules/cjs/loader.js:900:15)
at resolveExports (internal/modules/cjs/loader.js:432:14)
at Function.Module._findPath (internal/modules/cjs/loader.js:472:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Users\Enzo\Desktop\hipercore-nest\node_modules\@babel\preset-env\lib\polyfills\corejs3\usage-plugin.js:10:55)
at Module._compile (internal/modules/cjs/loader.js:1063:30) {
code: 'MODULE_NOT_FOUND',
path: 'C:\\Users\\Enzo\\Desktop\\hipercore-nest\\node_modules\\@babel\\compat-data\\package.json'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `babel-node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
This version of code not working anymore. I have tried installing with npm install
but it's not installing all the required packages. As a result it's not running using npm run start
I'm following the docs to try out nest and I've not jumped on the typescript bandwagon just yet, but I was under the impression that this repo would contain standard js code... Is this the right place to start for someone not using typescript? The files in src
have .js extensions but the code is still typescript.
nest n -l js myproject
npm run start:dev
Then I get this error:
Support for the experimental syntax 'classProperties' isn't currently enabled
Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.
npm install --save-dev @babel/plugin-proposal-class-properties
["@babel/plugin-proposal-class-properties"]
in the plugins array in .babelrc
Hope this can help :)
How to use decorators like @Param
in project with JavaScript?
I use nestjs/javascript-starter but I don't know to to build dist for run in production ?
Thank you
Hi there,
I cloned this repo and it looks like when I try to use nest-cli commands such as nest build
or nest start
I get this error
Error Could not find TypeScript configuration file "tsconfig.build.json". Please, ensure that you are running this command in the appropriate directory (inside Nest workspace).
This, I assume is because the default language when you nest start
is TypeScript. Using npm start
is fine, but I'm not too sure about using babel-node
in a production environment since the babel-node docs explicitly say it's not meant for production.
Right now my work around is to transpile manually using babel-cli using something that looks like this npx babel src/ --out-dir dist/
and then I just node dist/main.js
on the prod server.
My question is, am I missing something entirely about nest-cli usage? Or am I going about this in an acceptable way since the build should just be a transpilation anyways?
Thanks in advance
I started this template repo.
but I can't use @Body decorator in parameter.
after 3hours, I researched that as drilling
I can find the issue with babel.
Plz add this package and code in .babelrc file for starter nestjs/JS
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.