Running npm run build command fails with the error as shown in the screenshot.
As it may be seen from the following images, the file does exist.
Here is the version info
node v14.17.6
npm 9.1.3
Mac OS 12.5.1 (Monterey)
vue/cli-service": "^3.9.0
vue: "^2.6.14
None of the solutions out there seem to work. npm run serve command works fine and it compiles successfully. However, npm run build runs into this issue.
I have tried deleting node_modules, package-lock.json, update node, npm, deleting /usr/local/lib/node_modules/npm folders. This error somehow has been persistent.
Any help would be appreciated.
CodePudding user response:
i'm not a expert or anything but all i can see is that you are doing something from a file like importing a function or variable but that file does not exist try checking the spelling of the file or go to to location of the file to confirm that the file is there (again speaking i'm not a expert)
CodePudding user response:
Since I attempted different things, I am not sure as to what exactly fixed it. But I will write the commands and code I have used below in case it helps someone else
Current version info
node v18.12.1
npm 8.19.2
Commands executed (not sure of the order now)
sudo npm install -g --unsafe-perm node-sass
npm rebuild
npm rebuild sass
npm i sass
npm i node-sass
sudo npm install -g n
nvm use node && npm update --global npm
npm cache clean
npm cache clean --force
npm cache verify
npm audit fix
npm audit fix --force
delete node_modeules and package-lock.json reinstall npm
rm -rf node_modules/
rm package-lock.json
npm i
export NODE_OPTIONS=--openssl-legacy-provider
uninstall core-js
Install core-js
npm i core-js
changed vue/cli-plugin-babel version to 5.0.0
"@vue/cli-plugin-babel": "^5.0.0",
npm i webpack --save
npm i --save node-polyfill-webpack-plugin
Here is the old vue.config.js
module.exports = {
pluginOptions: {
apollo: {
enableMocks: true,
enableEngine: true
}
}
}
Here is the new vue.config.js
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
module.exports = {
pluginOptions: {
apollo: {
enableMocks: true,
enableEngine: true,
},
},
configureWebpack: {
performance: {
hints: false,
},
},
chainWebpack: (config) => {
config.performance.maxEntrypointSize(400000).maxAssetSize(400000);
new NodePolyfillPlugin();
},
};
Inputs from various resources were used to resolve the issue. node_modules folder was deleted several times and npm i
command was executed the same number of times. Hope this helps.