Wed Apr 06 2022·2 min read
Photo by Jeremy Bishop
npm update command to solve the "Error
[ERR_PACKAGE_PATH_NOT_EXPORTED]: No 'exports'" and then run
npm audit fix --force if necessary. The
npm update command will update the
installed modules that have fuzzy versioning.
Open your terminal in your project's root directory (where your
file is) and run the following commands.
npm update npm audit fix --force
If the npm update command
fails, run it with the
--force flag as well.
npm update --force npm audit fix --force
The command respects semver and will update the packages with fuzzy version to the latest version and install missing packages.
The npm audit command scans your project for vulnerabilities and automatically installs compatible updates to vulnerable dependencies.
If the error is not resolved, try to delete your
package.json) files, re-run
npm install and restart
# 👇️ delete node_modules and package-lock.json rm -rf node_modules rm -f package-lock.json rm -f yarn.lock # 👇️ clean npm cache npm cache clean --force npm install
The error happens often in Next.js projects when issuing the
npm run dev
command and gets resolved after running
If that didn't help, try installing the @babel/helper-compilation-targets package as a development dependency.
Open your terminal in your project's root directory and run the following command:
# 👇️ with NPM npm install --save-dev @babel/helper-compilation-targets # ---------------------------------------------------------- # 👇️ with YARN yarn add @babel/helper-compilation-targets --dev
@babel/helper-compilation-targets package works with browsers and Node.js
and is used by
@babel/preset-env to determine which plugin should be enabled
based on the targeted environment.
If that didn't resolve your issue, run the
node -v command and make sure you
are running the long term supported version of Node.js.
You can issue the following command if you use
nvm install --lts
The command will install and switch to the long term supported version, which should resolve the issue.
The error often occurs when installing the latest version of Node, and rolling back to the long term supported version solves it.