Steps to resolve the issue of a missing server.js file or having an empty "start" script in the package.json file

Having trouble solving the path error in my package.json file. How do I correctly set the path? Is it a typo or is server.js missing in the project folder?

  1. Successfully ran npm install

  2. Encountered an error when running npm start within the project folder. Not being an expert, I examined the error and researched potential solutions. Attempted npm install -g to resolve the issue (worked for some users but not for me).

The error message is as follows:

reactApp git:(master) ✗ npm start

> [email protected] start /home/pck/reactApp
> node './http_server.js'

internal/modules/cjs/loader.js:651
    throw err;
    ^

Error: Cannot find module '/home/pck/reactApp/http_server.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:649:15)
    at Function.Module._load (internal/modules/cjs/loader.js:575:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:862:12)
    at internal/main/run_main_module.js:21:11
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node './http_server.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.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pck/.npm/_logs/2019-04-01T15_47_30_710Z-debug.log

In the package.json file:

 "scripts": {
    "start": "node '~/http_server.js'",
    "watch": "karma start karma.conf.js --singleRun=false",
    "test": "echo \"Error: no test specified\" && exit 1"

I also installed a package that included a http_server.js. Attempted to link http_server.js with the package.json file without success.

Answer №1

Have you located the http_server in your designated home directory?

Answer №2

After some trial and error, I successfully resolved the issue on my own. The only thing that needed fixing was the script path in the package.json file.

The initial script appeared as follows:

"scripts": {
    "start": "node '~/http_server.js'",

which I updated to:

"scripts": {
    "start": "node ../http_server.js",

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

Update to the newest Node version on Windows using npm

I'm encountering an issue while trying to update Node.js to the latest version on my machine. When I run the following commands through npm, I receive the error below: npm install -g n This is the error I encountered: npm ERR! code EBADPLATFORM npm ...

Module 'has-flag' not located

Encountering an error when running "npm run build" on the server. It works fine on my local machine, but I'm getting a 500 response on the server. Node version: 8.0 Npm version: 5.0.3 Error: Cannot find module 'has-flag' at F ...

Is npm required if Bower package cannot be found?

As I embark on my journey with Bower, I'm in the process of setting up a mock project. After initializing my project and installing jQuery and gulp to kick things off, everything seems to be going smoothly. These dependencies have been successfully ad ...

Downgrading the node version on a Mac continues to display the previously installed version

I am currently in the process of downgrading my node version on a Mac terminal. sudo npm cache clean -f sudo npm install -g n sudo n 9.10.0 After executing the above commands, I checked the version and it remained the same as the previous version. npm - ...

The challenges of dealing with duplicate identifiers caused by nesting npm packages in TypeScript

I am facing an issue with my project structure where I have a node_modules folder at the root level and another one within a subfolder named functions. The directory layout looks like this, ├── functions │   ├── index.js │   ├── ...

Getting rid of Glyphicons in Laravel 5.4

I am currently working on a project using laravel-5.4 and I need to remove Glyphicons from it. To achieve this, I executed the following command from the root folder of my project: npm uninstall glyphicons-halflings After running npm run production, the ...

Issue: Module 'browser-sync' not found

Whenever I attempt to run gulp serve, an error is thrown. module.js:338 throw err; ^ Error: Cannot find module 'browser-sync' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:278:25) ...

Reorganize child JSON objects into a new object that includes a parent ID

Exploring the realm of JavaScript, I am currently delving into Node.JS to interact with an API and save the data in a SQL Server. Utilizing the "request" and "mssql" Node packages for this task as they possess robust documentation and support. My query re ...

Issue with remote URL mismatch when attempting to upload to Git using angular-gh-pages

I have just completed transitioning my project to use an angular workspace and now I am looking to deploy my demo application using angular-gh-pages. The repository link is https://github.com/Gillardo/ngx-bootstrap-datetime-popup In my package.json, I hav ...

Display only the essential NPM audit errors during the Azure Pipeline build process

When running NPM audit on my Azure Pipeline build, I am utilizing a custom command: npm audit --registry=https://registry.npmjs.org/ | Select-String -Pattern ( "Critical") -Context 0,10 The purpose of this command is to only fail the step if t ...

Creating Excel documents using Angular and XLSX template generator

In my Angular application, I am utilizing the XLSX library to manipulate an Excel file. The file I start with is encoded in base64 format, so my first task is to decode it, make some changes to specific cells, and then save the modified file back in base64 ...

Solution: How to fix the error: Invalid component type, 'Draggable' cannot be used with JSX in react-draggable

I encountered an error while working on this Next.js React project Type error: 'Draggable' cannot be used as a JSX component. Its instance type 'Draggable' is not a valid JSX element. The types returned by 'render()&apo ...

NPM packages: Providing a comprehensive assets and images delivery solution package

After creating a custom (angular2) npm package and uploading it to my personal registry, I encountered an issue with delivering the icons along with the component. The component should display an icon by using the following template: <span [class]="& ...

Unable to incorporate external JavaScript library into Laravel project

I'm facing a challenge in incorporating the bs treeview.js library into my Laravel project and need some guidance. Thus far, I have taken the following steps: npm install --save bstreeview I included require ('bstreeview'); in resources/js/ ...

The application unexpectedly stopped running while using nodemon

Recently, I've been having trouble running a nodejs application in debug mode using Git Bash. While I've done it successfully several times before, the most recent attempts have not been working. When I enter the command: npm run startwindows:i ...

Running an SSH shell script through an npm command

Currently, I am working on developing an npm script to run an SSH shell command. The script currently utilizes an osascript command to open a Terminal window and execute the desired command. I am looking to update the script to make it execute the command ...

Npm issue. I'm unable to successfully install any packages as it keeps throwing an error

Issue: Error Encountered: Windows_NT 6.1.7601 Error occurred in the Windows_NT environment using the specified node and npm versions with error code EPEERINVALID. The package <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data ...

What have I recently downloaded using NPM?

While attempting to install a package manager called NPM, I encountered an unexpected issue. The command that I entered was: sudo npm install foever -g Due to a typographical error, I mistakenly typed "foever" instead of "forever." Surprisingly, the sy ...

Installing npm on a Create React App applicationI just installed npm on my brand

After successfully creating an app with Create React App, I decided to try running npm install in a new folder, but encountered issues. My goal is to test this app so that I can share its source code without including the bulky node_modules folder. Unfort ...

The error message in angular-gridster2.mjs states that the export 'debounceTime' imported as 'debounceTime' was not found in the 'rxjs' module

Recently, I made the decision to upgrade my Angular version from 12 to 14. Throughout this process, I encountered numerous errors which I was able to resolve. However, one particular error has me stumped. The angular-gridster2.mjs package is among the newl ...