. Advertisement .
. Advertisement .
The error: “Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./lib/tokenize’ is not defined by “exports”” is a common error that can show up in many ways. In this blog, we will go through some of the ways you can fix this issue. Read on.
What is “Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./lib/tokenize’ is not defined by “exports””?
When attempting to run my Reactjs project, you may get the following problem whenever you run the npm start command.
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in package.json
Cause of error
Most likely the above function runs unstable on the version you are using, thus causing the above error. The workaround for you is to try to install another version.
How to fix it?
Here are some solutions for you. Each method is shown in detail step by step, please read carefully and choose the right method for you.
Approach 1: Install the stable version v14.18.1
Simply downgrade nodejs to the LTS version to resolve this issue. So, all you have to do is install node.js v14.18.1 and uninstall the newest version, then install the stable version v14.18.1 (For now).
Utilize this command to uninstall an older version of node:
nvm uninstall <Your version>
If you’d like to uninstall Node version 17.0.1, utilize this command:
nvm uninstall v17.0.1.
Then, instead of using the unstable version LTS, which is v14.18.1, use the stable version LTS. Simply execute the following command:
nvm install –-lts.
Now, you have solved your issue.
Alternatively you can also run the following command.
rm -rf node_modules yarn.lock yarn add -D react-scripts@latest yarn build
or if you use npm:
rm -rf node_modules package-lock.json npm install -D react-scripts@latest npm install npm run build
Approach 3: Using the node version 17.4.0
if the above doesn’t work for you, you can try to install node version 17.4.0 and run the following command:
npm install react@latest react-dom@latest npm install next@12
Approach 4: Reinstall node packages
Simply reinstall node packages to see if it helps.
- Delete the node modules folder and the .lock file first.
- Then, using npm or yarn, install your packages again. Using command:
`npm install --legacy-peer-deps`
- Restart your project now with:
- Hopefully, your problem can be resolved.
We hope you enjoyed our article about the error. With this knowledge, we know that you can fix your error: “Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./lib/tokenize’ is not defined by “exports”” quickly by following these steps! If you still have any other questions about fixing this syntax error, please leave a comment below. Thank you for reading!