When running the command npx create-nx-workspace@next my-app --preset=full-stack i expect the workspace to work without any errors/warnings.
When running npx create-nx-workspace@next my-app --preset=full-stack the application is created as it should without any warnings.
The problem occurs when running npm start, i will then get the following warning:
WARNING in Failed to read entry point info from C:/Development/successful-workspace/node_modules/@nestjs/schematics/lib/application/files/js/package.json with error SyntaxError: Unexpected token < in JSON at position 509.
I tried to ignore this error and visited localhost:4200 but then this error occurs and no data is fetched from the api:
[HPM] Error occurred while trying to proxy request /api/hello from localhost:4200 to http://localhost:3333 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
WARNING in Failed to read entry point info from C:/Development/successful-workspace/node_modules/@nestjs/schematics/lib/application/files/js/package.json with error SyntaxError: Unexpected token < in JSON at position 509.
This error occurs because there is some 'templating' syntax in the package.json that doesn't get replaced.

[HPM] Error occurred while trying to proxy request /api/hello from localhost:4200 to http://localhost:3333 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
I am not sure why this doesn't work, but it could be because of error 1.
Please provide detailed steps for reproducing the issue.
npx create-nx-workspace@next my-app --preset=full-stack npm startI also did:
npx create-nx-workspace@next my-app --preset=full-stack npm installnpm startand:
npx create-nx-workspace@next my-app --preset=full-stack npm installnpm startPlease provide any relevant information about your setup:
Thanks for all the wonderful detail in this issue. However, I think the expectations about how the repo should work are mistaken due to our lack of explanation.
The frontend and the backend (api) are two different applications.
To run the frontend:
npm start`/`npm start -- my-app
To run the api:
npm start -- api
To run them both at the same time, either run them in separate terminals are use concurrently:
npx concurrently "npm start -- my-app" "npm start -- api"
What would be a better way of explaining this? Perhaps the preset should log this out?
Thanks for the clarification @FrozenPandaz my post consists of 2 errors.
After your explanation I am now enable to run both backend and frontend applications! 馃憤
What would be a better way of explaining this? Perhaps the preset should log this out?
It would be awesome to log out the "how to start" information when using the --preset flag.
I also i think it would be nice to add a script in package.json that executes both environments.
I am getting a warning when using the command npm start -- api
I expect this is a issue belongs to the @nestjs package and not the nx.
WARNING in Failed to read entry point info from C:/Development/successful-workspace/node_modules/@nestjs/schematics/lib/application/files/js/package.json with error SyntaxError: Unexpected token < in JSON at position 509.
As I understand it, a NestJs project is handled as a app in the NX workspace, the reason that i think this is because the nestjs project lives in the apps/ folder.
I think it would be good to separate the backend from the frontend when working in a nx workpace:
A problem i can see with the current workspace setup is that it will be quite messy to start the application if i decide to create microservice apis. The port usage will also be a problem, but i guess this is not a NX issue, but it would be a nice feature in the future :)
So to be able to run the web-client-app i will need to call:
npx concurrently "npm start -- web-client-app" "npm start -- user-api" "npm start -- user-settings-api" "npm start -- employee-api" "npm start -- address-api"
@stefan-karlsson you can separate backend and frontend apps as follows:
apps/
backend/
myapi
frontend/
myapp
There are many dimensions you can use to separate your apps and libs (e.g., where it runs: backend, frontend, nativescript, e2e, who owns it: my team, that team, etc..) You can devise your own folder structure to reflect that.
@FrozenPandaz we need to look at why nestjs schematics are accessed are used when running a nest app. They should not be.
@vsavkin you can use also concurrently "npm:start-api-*"
and make some tasks like:
start-api-auth, start-api-clients, start-api-employees etc...
Any progress or fixes regarding the warning:
WARNING in Failed to read entry point info from C:/Development/successful-workspace/node_modules/@nestjs/schematics/lib/application/files/js/package.json with error SyntaxError: Unexpected token < in JSON at position 509 ? ... as this makes development really slow, because I have to re-compile the whole app when I changed my code.
@svnba for me it shows only once, after first build. Next builds does not print that "warning".
I ended up setting up a new project. I copied all the files over to the new project. Works like a charm.
@angular-devkit/architect 0.800.1
@angular-devkit/build-angular 0.801.2
@angular-devkit/build-optimizer 0.801.2
@angular-devkit/build-webpack 0.800.1
@angular-devkit/core 8.0.1
@angular-devkit/schematics 8.0.1
@angular/cdk 8.1.1
@angular/material 8.1.1
@ngtools/webpack 8.1.2
@schematics/angular 8.0.1
@schematics/update 0.801.2
rxjs 6.5.2
typescript 3.4.5
webpack 4.29.0
When running ng serve npm start -- app or ng serve app (angular application) error below is shown
WARNING in Failed to read entry point info from /home/user/Documents/projects/project/node_modules/@nestjs/schematics/lib/application/files/js/package.json with error SyntaxError: Unexpected token < in JSON at position 509.
When doing ng serve server (which is nestjs) no warnings occur.
I got this warning when VSCode had auto-imported a class from a shared lib by it's relative path eg. import { MyInterface } from '../../../../libs/interfaces'.
Importing it via the correct scope fixes it, eg. import { MyInterface } from '@my-org/interfaces'.
It's very weird indeed that the error points toward @nestjs though it only happens when building an Angular app. Not very helpful. :)
I ended up setting up a new project. I copied all the files over to the new project. Works like a charm.
If this is the solution it feels like a piece of work to go through. But this is getting pretty annoying I must say.
Ran into this again. This time I can't find any import scope issues in my code. Look at the package.json pointed at by the error message, it's these kind of lines that cause the problem. Eg. node_modules/@nestjs/schematics/lib/application/files/ts/package.json
"@nestjs/platform-express": "^6.0.0", <% if (dependencies.indexOf('microservices') !== -1) { %>
"@nestjs/microservices": "^6.0.0", <% } %><% if (dependencies.indexOf('websockets') !== -1) { %>
"@nestjs/websockets": "^6.0.0", <% } %>
I donno who's supposed to do something with those conditionals, but it's failing. If you remove all those non-json invalid stuff <% ... %> problem goes away. Now I'm perhaps always importing things I possibly don't need like microservices/websockets?
Will close this since it is not a issue anymore