next.js - how to fix issue with npm run build - npm

I have a project on a test server which I am able to deploy successfully with npm run build
Now I am trying to deploy it on the production server but I am getting the following error:
/home/clients/7cb14b18a04cde30fa48b73997f5d66d/sites/americanmarket.ch/node_modules/next/dist/telemetry/storage.js:101
notify = ()=>{
^
SyntaxError: Unexpected token =
at Module._compile (internal/modules/cjs/loader.js:721:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/clients/7cb14b18a04cde30fa48b73997f5d66d/sites/americanmarket.ch/node_modules/next/dist/build/index.js:37:16)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! american-market#0.1.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the american-market#0.1.0 build 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/clients/7cb14b18a04cde30fa48b73997f5d66d/.npm/_logs/2022-12-29T10_34_13_423Z-debug.log
What I tried to do to fix the issue was to check the versions for packages like next, react and react-dom on the test server and use the exact same versions in the package.json for the prod server. I deleted the node_modules folder and package-lock.json file I tried an npm install and npm run build again but I still got the same error.
At this point I'm not too sure how I can fix this issue.

Hi #Jolan,
It is hard to tell you what cause this error message. But, There are a few things.
It's possible If you are using a version of Node.js that is older than the version that you used on the test server, certain features of your code that are supported in newer versions of Node.js may not work in the older version. This could cause syntax errors or other issues when you try to run your code. First, try to run this command and see if Babel able to transpile your code successfully, babel src --out-dir build. Then check node version by run that node -v.
Most of the time I see the issue could be related to Babel, which is a JavaScript transpiler that allows you to use newer JavaScript syntax in older environments. If you are using Babel in your project, and you are seeing syntax errors like Unexpected token =, it could be because Babel is not correctly transpiling your code.
Maybe you need to clear the NPM cache and then run NPM install again.
npm cache clean --force.
If you are still unable to resolve the issue, then, you need to check the logs for more infomation.
As Mr.#Canberk Sahin described.
Can you check the debug log from here /home/clients/7cb14b18a04cde30fa48b73997f5d66d/.npm/_logs/2022-12-29T10_34_13_423Z-debug.log

Related

Vue 2 app, pull down latest, getting error, workign for everyone else

I've got a vue 2 project.
Other folks get latest in TFS and it works, only failing on my box
I deleted the old folder, force get currrent version, cd to src folder, Npm install, npm run serve
Get this error.
10 warnings found. INFO Starting development server... ERROR
Error: #vitejs/plugin-vue requires vue (>=3.2.13) or #vue/compiler-sfc
to be present in the dependency tree. Error: #vitejs/plugin-vue
requires vue (>=3.2.13) or #vue/compiler-sfc to be present in the
dependency tree.
at Object. (D:\TFS\StudentPortal4Vue_1_1\clientapp\node_modules\vue-loader\dist\compiler.js:14:15)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object. (D:\TFS\StudentPortal4Vue_1_1\clientapp\node_modules\vue-loader\dist\index.js:8:20)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) npm ERR! code ELIFECYCLE npm
ERR! errno 1 npm ERR! student-portal#1.1.0 serve: vue-cli-service lint --fix && vue-cli-service serve --open npm ERR! Exit status 1 npm
ERR! npm ERR! Failed at the student-portal#1.1.0 serve 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!
C:\Users\Brown.ericw\AppData\Roaming\npm-cache_logs\2022-03-07T18_01_49_062Z-debug.log
I compared the source, everything is the same, only the node folder is different
I got a copy of a coworkers local folder (Without node folders) working, did a compare by file looking for differences and testing.
Any idea what I'm doing wrong?
I figured it out, we have packages-lock.json checked in to source contorl. If I delete that before the "npm install" everything works as expected.
Going to remove it from source control.

How to resolve npm unmet dependency?

Problem
My web app uses Sequelize ORM along with ExpressJS for serving the back end and Handlebars templating on the front end.
Everything used to work fine but now I'm not able to run the server app due to an unmet dependency error.
Specifically, Sequelize has a dependency on uuid#^8.1.0 that I cannot seem to resolve.
I am familiar with NPM and Node as well as the other packages I am using and cannot resolve this dependency for the life of me.
What I Have Tried
Installing Sequelize and UUID packages globally using the command:
npm install -g sequelize
npm install -g uuid
I've also tried installing a Node package specifically made to resolve tricky npm dependency issues called 'npm-install-missing'. This also did not resolve the issue.
I've also tried 'npm upgrade' but receive an error stating that uuid is outside the uuid package which I do not understand. Here is the resulting error from running 'npm upgrade':
C:\Users\benar\Documents\Dev\Test\NodeExpress\testwebproject>npm upgrade
npm ERR! code EEXIST
npm ERR! path C:\Users\benar\Documents\Dev\Test\NodeExpress\testwebproject\node_modules\.bin\uuid
npm ERR! Refusing to delete C:\Users\benar\Documents\Dev\Test\NodeExpress\testwebproject\node_modules\.bin\uuid: is outside C:\Users\benar\Documents\Dev\Test\NodeExpress\testwebproject\node_modules\uuid and
not a link
npm ERR! File exists: C:\Users\benar\Documents\Dev\Test\NodeExpress\testwebproject\node_modules\.bin\uuid
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\benar\AppData\Roaming\npm-cache\_logs\2020-08-08T19_18_39_086Z-debug.log
C:\Users\benar\Documents\Dev\Test\NodeExpress\testwebproject>
Someone left a comment with the suggestion to uninstall both sequelize and uuid then install uuid and sequelize again in that order. After doing this, I attempted to run my app again and received the following error which I'm fairly certain is the same as before:
C:\Users\benar\Documents\Dev\Test\NodeExpress\testwebproject\node_modules\uuid\dist\esm-browser\index.js:1
export { default as v1 } from './v1.js';
^^^^^^
SyntaxError: Unexpected token 'export'
at wrapSafe (internal/modules/cjs/loader.js:1172:16)
at Module._compile (internal/modules/cjs/loader.js:1220:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1277:10)
at Module.load (internal/modules/cjs/loader.js:1105:32)
at Function.Module._load (internal/modules/cjs/loader.js:967:14)
at Module.require (internal/modules/cjs/loader.js:1145:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (C:\Users\benar\Documents\Dev\Test\NodeExpress\testwebproject\node_modules\sequelize\lib\utils.js:7:16)
at Module._compile (internal/modules/cjs/loader.js:1256:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1277:10)
[nodemon] app crashed - waiting for file changes before starting...
What else can I try to fix this issue?

How to undo/revert "npm audit fix"

As the title says. I have run npm audit fix in cmd. Now I can't run npm run build as it gives me errors. How to undo npm audit fix? Is there such command?
After running npm audit fix I get this errors:
D:\SUBLIME\REACT>npm run build
> uploadpublish#1.0.0 build D:\SUBLIME\REACT
> webpack --mode production
D:\SUBLIME\REACT\node_modules\webpack-cli\bin\config-yargs.js:136
describe: optionsSchema.definitions.output.properties.path.description
^
TypeError: Cannot read property 'properties' of undefined
at module.exports (D:\SUBLIME\REACT\node_modules\webpack-cli\bin\config-yargs.js:13
at D:\SUBLIME\REACT\node_modules\webpack-cli\bin\webpack.js:59:27
at Object.<anonymous> (D:\SUBLIME\REACT\node_modules\webpack-cli\bin\webpack.js:514
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! uploadpublish#1.0.0 build: `webpack --mode production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the uploadpublish#1.0.0 build 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! C:\Users\VERYNICE\AppData\Roaming\npm-cache\_logs\2020-06-10T14_43_53_493Z-debug.log
Unfortunately, an undo function does not exist in npm, so keeping the previous state of the package.json file and, if present, the package-lock.json and the npm-shrinkwrap.json (these files are optionally) to restore it via npm install (or short: npm i) is the way to go.
Normally, in a situation like yours, you would simply revert all changes to package.json and package-lock.json with a version control system like git. Of course, you can do this manually, too, if you have saved the previous version of these files somewhere. A present npm-shrinkwrap.json file is not affected by an npm update and therefor must not be restored.
Afterwards you can install the old version of your project's dependencies with npm i.
Keep in mind, that the package-lock.json takes precedence over package.json and the package.json file uses Semantic Versioning (semver). And the npm-shrinkwrap.json file takes precedence over both files. There are even some more subtle differences, but I think this goes too far for this answer.
For more details, you can refer to these docs:
npm install
package.json
package-lock.json
npm-shrinkwrap.json
So I hope you have a backup or a previous git commit somewhere. Otherwise you could try to resolve the error by trying to read the error message and use an older version of the package which throws this error (webpack in you case). Also the dependencies of this package could be the reason for the problem. But take your time, if you decide to go this way. Good luck! :)
I had a slightly different problem. I ran npm audit fix --force while developing my app, and my project failed to compile when I tried to run npm start. I saw the previous answer, and found more information about npm auditin this article on Overreacted.
I ran git status to make sure the changes to package.json and package-lock.json were not yet staged for commit. Then, I ran git restore package-lock.json and git restore package.json. Then, I ran npm install again, and the app was able to compile.
I manually copied my package.json and package.lock.json from my previous commit, then I did an 'npm install' and rebuilt my React native app. It worked perfectly!
I also had a similar kind of problem. while I developing my app I ran the command "npm audit fix --force". It upgraded all my dependencies and could not run my app.
What I did was in the below to fix the problem
first I deleted both package.json and package-lock.json
then also deleted node_modules folder.
then restore the previous version of package.json, package-lock.josn and node_modules folder. (to restore process you can use a version controller like Git)
thats worked well with my issue.

ERROR Error: Cannot find module '#xtuc/long'

I am learning vueJs, I have installed my project using CLI and by project has successfully installed, the problem come when i need to run my project via terminal with a command npm run serve, below is the error that occur after running the command
$ npm run serve
> school#0.1.0 serve C:\Users\Mr chomvu\Documents\vueproject\school
> vue-cli-service serve
INFO Starting development server...
ERROR Error: Cannot find module '#xtuc/long'
Error: Cannot find module '#xtuc/long'
at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (C:\Users\Mr
chomvu\Documents\vueproject\school\node_modules\#webassemblyjs\wast-
printer\lib\index.js:10:36)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js
(internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! school#0.1.0 serve: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the school#0.1.0 serve 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! C:\Users\Mr chomvu\AppData\Roaming\npm-cache\_logs\2019-
06-08T13_11_37_227Z-debug.log
I do expect after successfully compilation to have a local:
https://localhost:8080
I have attached the error image:
If you don't make any changes in project, just you trying to install and run your first vue.js app then follow this guide Creating a Project CLI, and everything will be fine.
Be sure you using the latest version of node & npm.
If you want to fix this project try remove node_modules and the package-lock.json file, and than run npm install

Error: Cannot find module '#angular/tsc-wrapped/src/tsc' ionicjs ionic view

I get following error when try to compile ionic 3 app with ionic-view (www.ionicjs.com)
Error: Cannot find module '#angular/tsc-wrapped/src/tsc'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (/usr/src/app/node_modules/#ionic/app-scripts/dist/aot/aot-compiler.js:7:13)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
npm info lifecycle MedMan#0.0.1~build: Failed to exec build script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! MedMan#0.0.1 build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the MedMan#0.0.1 build 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/gitlab-runner/.npm/_logs/2017-09-25T14_14_22_583Z-debug.log
/snapshot.sh: line 32: [: missing `]'
npm run build failed
Make sure your project has a build script in the package.json
Failed to upload build to storage please retry your build.
Running after script...
$ clean-up
Cleaning up files...
Successful clean up
ERROR: Job failed: exit status 1
I work with following Versions:
"#angular/tsc-wrapped": "4.4.3",
"#ionic/cli-plugin-ionic-angular": "1.4.1"
"ionic": "3.12.0",
"rxjs": "^5.4.3",
"tslint": "^5.7.0",
"tslint-loader": "^3.5.3"
npm v 4.6.1
node v 8.5.0
None of the solutions at the web can solve this issue for me.
I guess this should fix it:
upgrade npm to the latest version (5.3.0), I personally stayed at 5.1.0 because there were issues with ionic and version 5.2.0 but I think it is fixed in the current version
rm -rf node_modules package-lock.json (on Windows: delete node_modules and package-lock.json manually)
npm install
If it still does not work you can try to manually install tsc-wrapped:
npm install --save-dev #angular/tsc-wrapped
Try this:
npm install npm#latest -g
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli#latest
npm install #angular/tsc-wrapped autoprefixer
https://github.com/angular/angular-cli/issues/3183#issuecomment-261740427
I additionally had to (but dont think this is only related to my case):
npm rebuild node-sass