When Typescript and React Native Imports Clash in an Express App, Resolving the Conflict of "npm run build" Command

When running my Express app using 'npm run serve', defined as 'npm run build && node lib/index.js' in the package.json scripts serve section, I encounter multiple duplicate declaration errors after installing React Native for a separate project:

https://i.stack.imgur.com/wJUYL.png

https://i.stack.imgur.com/Oxs12.png

There is no mention of React Native in my Express project and the react-native package is not even installed in my node modules. Prior to adding React Native to another project, the 'npm run build' command worked without issues. It seems like something might have changed due to the installation of React Native.

Answer №1

Big shoutout to @TheGreatZab for putting this to the test!

Please share your solution here to assist others experiencing the same issue.

The root cause lies in an additional node_modules/package.json residing in higher-level directories, setting off a chain reaction of issues.

Resolution:

Delete any node_modules and package.json files found in parent or grandparent directories

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Setting up routes in VueJS and NodeJS Express for API integration: a comprehensive guide

My API routes always return HTML instead of JSON, despite trying numerous solutions that have all failed. Here is my current setup: // app.js const express = require("express"); const app = express(); const history = require("connect-history-api-fallback ...

Attempting to create a JavaScript class within an HTML document

Having an issue with instantiating a JavaScript class in a separate HTML file. The JavaScript class looks like this: class Puzzle { constructor(fenStart, pgnEnd) { this.fenStart = fenStart; this.pgnEnd = pgnEnd; } } module.exports = Puzzle; ...

Excluding Gitlab's node_modules from the .gitignore: How to modify and upload a module?

I've added node_modules to .gitignore but now I need to update a module (Searchbar from reactnativeelements). What's the best and cleanest way to push this change to my GitLab repository? Creating a separate folder for the complete module and upd ...

Node.js and Binary.js combined for a safe and secure WebSocket implementation

My current setup involves streaming an mp3 file using Debian Jessie, Apache, Node.js, and Binary.js. Everything works smoothly when using http:// and ws://, but I'm encountering issues when trying to make it work with https:// and wss://. Even though ...

Top method for distributing database connection parameters with mongoose for node.js

Currently, I am utilizing Mongoose for managing a Mongo database. My connection file appears to be rather straightforward: var mongoose = require('mongoose') mongoose.connection.on("open", function(){ console.log("Connection opened to mongodb ...

Steps for sending an email one week later using Node.js

I have developed a script that sends a welcome email to users when they sign up for our app. I also want emails to be sent one after another. Now a cron job is running every minute, but I plan to change the frequency in the future. var job = new CronJ ...

Acquiring information from a website using Node.js

My experience with node.js is quite limited, and I am facing a challenge that seems more complex than it should be. Using the request npm module, I am trying to fetch content from a web page. The goal is to then utilize this content later in the program. H ...

Angular file upload component with customizable file size limits

I'm currently developing an upload file feature that will transmit the file via nodejs. However, I am encountering an issue related to file size. Whenever the file exceeds a few kilobytes, I encounter the following error: Error: request entity too la ...

The Vue.js application using pinia npm encounters a server error due to a variable being assigned a value but never utilized

I found this helpful video tutorial on how to fix that pesky error in my code, but I keep encountering the message: "error 'counter' is assigned a value but never used no-unused-vars". Can anyone point out what I might be overlooking? <temp ...

passport.js struggles to function properly on certain posts

Recently, I have encountered a problem with my node.js (express) app hanging on certain posts related to passport.js. While searching for solutions on stackoverflow, I came across two questions that might provide some insights: More Passport.js woes - han ...

NodeJs causing issues with reloading AngularJs routes

I was able to successfully create a sample app by following a few examples, but I've encountered an issue that I'm struggling to resolve. In my Angular app, the routes work fine like this: - http://localhost:8888/#/login works However, when I re ...

What is the method used for defining an element within an array in JavaScript?

As I am new to JavaScript, I find myself trying to organize callbacks within an array. An example of what I have been working on: items = [ "test" = async message => { let userCoins = editCurrency('fetch', message.guild. ...

What is the best way to transform an array of objects into a single string in JavaScript?

After receiving the input from req.body, it looks like this: [ { "Name": "Test_1", "Level 1": "Story_1", "Level 2": "Story_1.1" }, { "Name": & ...

Leveraging Node modules alongside Flow

Flow includes built-in support for common Node modules like "fs". What is the correct way to utilize them? I attempted the following: const fs: fs = require('fs'); fs.someUnknownMethod(); I was anticipating Flow to catch that last line as an er ...

What is the difference between TypeScript's import/as and import/require syntax?

In my coding project involving TypeScript and Express/Node.js, I've come across different import syntax options. The TypeScript Handbook suggests using import express = require('express');, while the typescript.d.ts file shows import * as ex ...

Express Promises Linked Together: Lack of Data in Last Stage

When handling put requests for my restful API, I utilize the findOneAndUpdate method of Mongoose. The password is left to the second step where the 'save' pre hook of Mongoose is used to hash the password. router.put("/:id", function(req, res, n ...

Managing various types of content in a Node.js application

I am currently working on an API in Node.js that will be accessed by various applications. These applications may make calls with different content types, so I have implemented the body-parser to parse the request data. To ensure consistency and proper fu ...

`Is it possible to retrieve Wikipedia information directly from a Wikipedia link?`

Is there a way to create a feature where users can input a Wikipedia page link and retrieve all the text from that page? I am working on adding a functionality to my website where users can paste a link to a Wikipedia page they want to analyze into an inp ...

Strategies for responding to the following prompt depending on the outcome of the previous prompt in Node.js

When using child_process to execute command line tasks in Node.js, I encountered a challenge. While I know how to pass parameters to a command like this echo 'y\ny' | ..., my issue is more complex. I need to pass the second parameter based o ...

Expressjs makes it easy to upload audio files to your website

Currently, I'm developing a music app and I'm looking for the best way to upload an audio file in my ExpressJS application. Is it possible to use Cloudinary or is there another method that is more efficient? I attempted to follow the same proces ...