question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

node_modules/@nestjs/schematics/dist/lib/resource/files/ts/entities/name@singular.entity.ts breaks NPM commands

See original GitHub issue

Bug Report

In the last 2 days I noticed an error in my pipeline after npm install, which breaks the whole pipeline from succeeding. The error seems to be caused by a file inside node modules which is interpreted by typescript and failes.

Current behavior

I am using Gitlab pipelines to push the code to a DigitalOcean droplet. After npm install when I try to run migrations, I started to see this error: Error during migration run: backend/dist/node_modules/@nestjs/schematics/dist/lib/resource/files/ts/entities/name@singular.entity.ts:1 <% if (type === ‘graphql-code-first’) { %>import { ObjectType, Field, Int } from ‘@nestjs/graphql’; ^ SyntaxError: Unexpected token ‘<’

The error is replicable only on the Digital Ocean server which operates on Ubuntu 20.04. I cannot replicate it on my machine as the file is not found inside node_modules.

Input Code

The content of the file from node_modules/@nestjs/schematics/dist/lib/resource/files/ts/entities/name@singular.entity.ts:1 is:

<% if (type === 'graphql-code-first') { %>import { ObjectType, Field, Int } from '@nestjs/graphql';
@ObjectType()
export class <%= singular(classify(name)) %> {
  @Field(() => Int, { description: 'Example field (placeholder)' })
  exampleField: number;
}<% } else { %>export class <%= singular(classify(name)) %> {}<% } %>
</

Expected behavior

This file should either be removed or fixed somehow as the content inside it is clearly not typescript and that`s why it is failing: node_modules/@nestjs/schematics/dist/lib/resource/files/ts/entities/name@singular.entity.ts

Environment

Nest version: 7.0.0

For Tooling issues:

  • Node version: node: 12.18.3, npm: 6.14.6
  • Platform: Ubuntu 20.04.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
masurceaccommented, Aug 27, 2020

@Malak67 Looks like it’s an issue when TypeORM tries to load entities from node_modules folder. I had the same problem and fixed it by changing the entities property as shown below: from entities: [join(__dirname, './**/*.entity{.ts,.js}')] to entities: [join(__dirname, 'apps/backend/src/**/*.entity{.ts,.js}')].

Hope this solution matches your case too!

1reaction
kamilmysliwieccommented, Sep 8, 2020

I’ve just published a new @nestjs/schematics@7.1.2 release which dynamically updates the entity template filename. In this case, even if the wrong glob path is specified in the TypeOrm settings, the template file should be ignored.

Read more comments on GitHub >

github_iconTop Results From Across the Web

entity-cli - npm
generate typeorm, mongoose, sequelize entities by cli. Latest version: 1.1.32, last published: a year ago. Start using entity-cli in your ...
Read more >
concurrently - npm
I like task automation with npm but the usual way to run multiple commands concurrently is npm run watch-js & npm run watch-css...
Read more >
ts-node - npm
TypeScript execution environment and REPL for node.js, with source map support. Latest version: 10.9.1, last published: 5 months ago.
Read more >
entities - npm
Encode & decode HTML & XML entities with ease & speed. Features. Tried and true: entities is used by many popular libraries; eg....
Read more >
Common errors | npm Docs
Broken npm installation; Random errors; No compatible version found; Permissions errors ... You can do this from the command line or the website....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found