Encountered an error while building module in Laravel 6 project

I recently set up a new project using Laravel 6 and encountered an error after running `npm run watch` following the npm installation.

Ahmed@DESKTOP-G216VK0 MINGW64 /c/laragon/www/larabiz
$ npm run watch

> @ watch C:\laragon\www\larabiz
> npm run development -- --watch


> @ development C:\laragon\www\larabiz
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"        

10% building 1/1 modules 0 active
webpack is watching the files…

98% after emitting SizeLimitsPlugin

 ERROR  Failed to compile with 1 errors                                                                                                                         9:37:44 PM
 error  in ./resources/js/app.js

Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Package exports for 'C:\laragon\www\larabiz\node_modules\@babel\helper-compilation-targets' do not define a '.' subpath
    at applyExports (internal/modules/cjs/loader.js:485:15)
    ...

 @ multi ./resources/js/app.js ./resources/sass/app.scss

       Asset      Size   Chunks             Chunk Names
/css/app.css   0 bytes  /js/app  [emitted]  /js/app
  /js/app.js  7.86 KiB  /js/app  [emitted]  /js/app

ERROR in ./resources/js/app.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Package exports for 'C:\laragon\www\larabiz\node_modules\@babel\helper-compilation-targets' do not define a '.' subpath
    ...

Here's the content of the Package.json file:

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        ...
    },
    "devDependencies": {
        "babel-core": "^6.26.0",
        "babel-loader": "^7.1.4",
        ...
    }
}

Answer №1

Hey there, I encountered this problem earlier today.

update: Prior to attempting this solution, I experimented with downgrading babel and updating node, but unfortunately that didn't resolve the issue for me

What ultimately worked for me was uninstalling nodejs, deleting the npm and npm-cache folders from AppData, restarting my system, and then reinstalling nodejs.

And just like magic, it started working again!

Answer №2

I successfully resolved the issue by updating to nodejs version 13.6.0 and following these steps:

vagrant@ubuntu-bionic:~$ rm -rf node_modules
vagrant@ubuntu-bionic:~$ rm package-lock.json yarn.lock
vagrant@ubuntu-bionic:~$ npm cache clear --force
vagrant@ubuntu-bionic:~$ npm install cross-env
vagrant@ubuntu-bionic:~$ npm install 
vagrant@ubuntu-bionic:~$ npm run dev

It's important to mention that I needed to use cross-env due to my development setup involving a Windows 10 host and an Ubuntu Vagrant VM.

For more information, you can refer to the response from @JLHwung on this StackOverflow thread.

Answer №3

Insert the following code into your package.json file:

"@babel/preset-env": "^7.2.0"

Answer №4

Attention all Windows users: If you are utilizing chocolatey, simply execute this command in the terminal. Be sure to restart the terminal before attempting to run any development tasks for optimal performance:

choco upgrade nodejs

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 wiki.js on a virtual machine

[root@localhost html]# node -v v6.17.1 [root@localhost html]# npm -v 3.10.10 I have decided to install wiki.js on my virtual machine, which is based on node.js. Although I am not familiar with node.js, I want to set it up for future use. After following ...

Avoid opening the "Manage npm modules" option by right-clicking

I've been diving into Shawn Wildermuth's course on Node.js for .NET Developers and have successfully installed NodeJS Tools for Visual Studio from nodejstools.codeplex.com. After getting everything set up, I created a "NodeJS Blank Website." How ...

Ensure that the package.json file is updated if the local package version is not

As someone who is relatively new to node js and npm, I have noticed that there can be discrepancies between the packages installed on my system and those being installed by npm install or package.json. I am looking for a way to check the version of my loc ...

Having trouble installing NPM Live-server on zsh shell?

As I attempt to globally install live-server using the command: npm install -g live-server, I continue to encounter the following error message; mac@Edozie ~ % npm install -g live-server npm WARN deprecated <a href="/cdn-cgi/l/email-protection" class="_ ...

npm fails with the error message 'ERR! callback() was not invoked'

While attempting to set up vue-cli on my system, I encountered an issue with the installation process. npm install -g @vue/cli The error message I received was: Unhandled rejection Error: EACCES: permission denied, mkdir '/home/moeketsi/.npm/_cac ...

"Encountering an issue while installing Express with the Node Package Manager

While trying to install express using the node package manager on my Windows 7 x64 machine, I encountered the following error. I am running cmd as an administrator. Can anyone provide assistance? Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Mic ...

Guide to setting up a new create-react-app project after removing an existing one

(base) Dun-Yan:Web development.HTML ongdunyan$ sudo npm uninstall -g create-react-app Password: up to date, audited 1 package in 429ms found 0 vulnerabilities (base) Dun-Yan:Web development.HTML ongdunyan$ sudo npm install -global <a href="/cdn-cgi/l/ ...

Guide on transferring a Git repository to the main branch of a different repository

After completing the development of my template engine, Squirrelly, I have the current version saved in a GitHub repository at https://github.com/squirrellyjs/squirrelly, and the new version can be found at https://github.com/squirrellyjs/squirrelly-next. ...

Issue encountered during installation of [email protected] on a Windows 10 operating system

Encountered an error during the installation of [email protected] on a Windows 10 system. npm ERR! code ETARGET npm ERR! notarget No matching version found for <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ee998b8cddc38d8 ...

Tips for troubleshooting a node module that is part of a build process

When working on my applications, I often rely on the NPM package.json to handle my build tools. However, I've come across a module that seems to have a bug. I'm eager to debug it, but I'm unsure how to do so within the context of the build t ...

Developing a project using npm and Node.js with Typescript has been smooth sailing so far. However, an issue has arisen

Recently, I came across a helpful guide on setting up a Node.js project in Typescript on this website: https://basarat.gitbooks.io/typescript/docs/quick/nodejs.html The guide also provides instructions for auto-recompilation upon changes when using npm st ...

Laravel - executing npm run watch continuously without pause

After setting up Laravel on my Windows 10 machine using Visual Studio Code, I installed npm and node. Following Laravel's default package.json, I used the npm install command to run the installation process. The file remains unchanged and appears as f ...

Guide to running several versions of a single Next JS application with distinct configurations simultaneously on a shared server

My goal is to run 2 instances of the NextJS app on the same machine with different configurations and ports. The first instance runs on port 3000, while the second runs on port 3001, and this setup functions correctly with the commands: next dev next de ...

Issue encountered while trying to install PhantomJS through NPM / NodeJS

I'm facing an issue with installing PhantomJS in my Vagrant Box. The command "npm install phantomjs" is failing. After checking the extracted folder at "/tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-...", I noticed that the folder is em ...

The deployment process encountered an error: "bin/yarn: Permission denied"

Experiencing a deployment failure in production, it appears that yarn lacks the necessary permissions to read the file. How can I manage permission rights for yarn during deployment? Thank you Rails 6.1.3.1 // Node v15.5.1 // Tailwindcss: 2.1.1 Producti ...

In npm 5.5, what sets npm update apart from npm install @latest?

While reading the information about npm update, I came across a statement that when using it on global packages, such as npm update package-name -g, it should update to the @latest version. Unfortunately, this method did not work for me. As an alternative ...

An error notification received from the command "jspm install jquery"

As I follow the tutorial on the jspm.io site, everything goes smoothly until I reach step 3. When I try to execute jspm install jquery, an error message pops up. The error reads: warn Error on getOverride for jspm:github, retrying (2). ReferenceError: ui ...

Experiencing difficulty retrieving the variable within a NodeJs function

Currently, I am utilizing the NodeJS postgresql client to retrieve data, iterate through it and provide an output. To accomplish this, I have integrated ExpressJS with the postgresql client. This is a snippet of my code var main_data = an array conta ...

What separates the various methods of initiating a node+express application?

As I delve into the world of Node and Express, I've come across multiple methods for initializing an application. Specifically, I've been working on a project called "nodetest" and here are the initial steps I took: Firstly, I installed express ...

Encountering a 403 error while attempting to install Meteor with npm using the command npm install -

Following the installation instructions provided on the official Meteor website at , I encountered an error while trying to install Meteor using the command "npm install -g meteor". Here is the detailed error message: os  win 10 pro node -v  v14.15.1 n ...