`npm ERR! code 1` after SyntaxError when running `npm ci && npm run build` - node.js

I am trying to build and run a project on an npx dev-server. My package.json file has "type":"module" inside the first {} as recommended here. When I run npm ci && npm run build in terminal (MacOS Mojave), I get the following error message:
[!] SyntaxError: Unexpected token {
/Users/User/folder/project/node_modules/rollup-plugin-lit-css/rollup-plugin-lit-css.js:1
import { createFilter } from "rollup-pluginutils";
^
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:720:23)
at Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Object.require.extensions.<computed> [as .js] (/Users/User/folder/project/node_modules/rollup/dist/shared/loadConfigFile.js:622:13)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/Users/User/folder/project/rollup.config.js:7:14)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.require.extensions.<computed> [as .js] (/Users/User/folder/project/node_modules/rollup/dist/shared/loadConfigFile.js:619:20)
npm ERR! code 1
npm ERR! path /Users/User/folder/project/
npm ERR! command failed
npm ERR! command sh -c rollup -c && workbox generateSW
The debug logs give the following additonal error info:
22 verbose stack Error: command failed
22 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/#npmcli/promise-spawn/index.js:63:27)
When I try to run an npx server using npx #web/dev-server --root-dir static --app-index static/index.html, I get this error:
npm ERR! could not determine executable to run
I've tried updating npm through a number of methods:
npm rm -rf node_modules
npm install --legacy-peer-deps
but am still getting the same errors.
Any suggestions on where to start would be appreciated.

Had to update MacOS to Big Sur, then completely uninstall and reinstall node and npm.

Related

error when try to run npm build on react project

i'm trying to deploy my app via VPS (Ubuntu and Nginx) but this error keeps showing up, (on vs code it works fine) any idea how could i procede? thanks!
> mystery#0.1.0 build /home/react-projects/portfolio
> react-scripts build
/home/react-projects/portfolio/node_modules/eslint-webpack-plugin/node_modules/jest-worker/build/index.js:110
_ending;
^
SyntaxError: Unexpected token ;
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789: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:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/react-projects/portfolio/node_modules/eslint-webpack-plugin/dist/getESLint.js:9:5)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mystery#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mystery#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! /root/.npm/_logs/2022-08-23T18_10_04_282Z-debug.log
one way you can :
go to your package.json
replace "react-scripts": "..." to "react-scripts": "1.1.4",
then run npm install, after that npm build
if it didn't work try :
create a file .env at the root of the folder react folder
type SKIP_PREFLIGHT_CHECK=true inside of .env file
this command will help you in resolving this npm error.
then try to run npm build and check it should work .
notice : this command will permanently disable this preflight check
Updating node to higher version worked for me, i was using v10.22.1: nvm use --lts
i solved it installing the correct versions through NVM on my web server
https://www.freecodecamp.org/news/how-to-install-node-js-on-ubuntu-and-update-npm-to-the-latest-version/

problem with laravel and vue.js | Error: Cannot find module

I recently got this error whenever I install vue in laravel using the following commands:
composer require laravel/UI
PHP artisan up vue
php artisan ui vue --auth
npm install && npm run dev
I get this new error and its the first time that happened to me:
Error: Cannot find module 'webpack/lib/rules/DescriptionDataMatcherRulePlugin'
Require stack:
- C:\wamp64\www\projects\quizapp\node_modules\vue-loader\lib\plugin-webpack5.js
- C:\wamp64\www\projects\quizapp\node_modules\vue-loader\lib\plugin.js
- C:\wamp64\www\projects\quizapp\node_modules\vue-loader\lib\index.js
- C:\wamp64\www\projects\quizapp\node_modules\laravel-mix\src\components\Vue.js
- C:\wamp64\www\projects\quizapp\node_modules\laravel-mix\src\components\ComponentRegistrar.js
- C:\wamp64\www\projects\quizapp\node_modules\laravel-mix\src\Mix.js
- C:\wamp64\www\projects\quizapp\node_modules\laravel-mix\setup\webpack.config.js
- C:\wamp64\www\projects\quizapp\node_modules\webpack-cli\lib\webpack-cli.js
- C:\wamp64\www\projects\quizapp\node_modules\webpack-cli\lib\bootstrap.js
- C:\wamp64\www\projects\quizapp\node_modules\webpack-cli\bin\cli.js
- C:\wamp64\www\projects\quizapp\node_modules\webpack\bin\webpack.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (C:\wamp64\www\projects\quizapp\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at Object.<anonymous> (C:\wamp64\www\projects\quizapp\node_modules\vue-loader\lib\plugin-webpack5.js:6:42)
at Module._compile (C:\wamp64\www\projects\quizapp\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\vue-loader\\lib\\plugin-webpack5.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\vue-loader\\lib\\plugin.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\vue-loader\\lib\\index.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\laravel-mix\\src\\components\\Vue.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\laravel-mix\\src\\components\\ComponentRegistrar.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\laravel-mix\\src\\Mix.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\laravel-mix\\setup\\webpack.config.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\webpack-cli\\lib\\webpack-cli.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\webpack-cli\\lib\\bootstrap.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\webpack-cli\\bin\\cli.js',
'C:\\wamp64\\www\\projects\\quizapp\\node_modules\\webpack\\bin\\webpack.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! # watch: `mix watch`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the # watch 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\zzzab\AppData\Roaming\npm-cache\_logs\2021-08-05T07_08_51_267Z-debug.log
and I tried to make a new laravel project and didn't work.
Finally, i have the solution,
1- Delete the node_modules folder using the file explorer and delete package-lock.json as well.
2- Run npm install command.
3- Run npm run dev or npm run watch for auto mix when ever change made.

Keep getting missing module error when trying to do npm start

I keep getting the following error:
> kb-ui#0.0.1 start C:\Users\Tayeb\Desktop\F2f\bloomkonnect-fe
> webpack-dev-server --open --config webpack.dev.js --progress --watch
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module 'json-parse-better-errors'
Require stack:
- C:\Users\Tayeb\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js
- C:\Users\Tayeb\AppData\Roaming\npm\node_modules\webpack\lib\webpack.js
- C:\Users\Tayeb\AppData\Roaming\npm\node_modules\webpack-dev-server\bin\webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (C:\Users\Tayeb\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:7:19)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Tayeb\\AppData\\Roaming\\npm\\node_modules\\webpack\\lib\\Compiler.js',
'C:\\Users\\Tayeb\\AppData\\Roaming\\npm\\node_modules\\webpack\\lib\\webpack.js',
'C:\\Users\\Tayeb\\AppData\\Roaming\\npm\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! kb-ui#0.0.1 start: `webpack-dev-server --open --config webpack.dev.js --progress --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the kb-ui#0.0.1 start 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\Tayeb\AppData\Roaming\npm-cache\_logs\2021-06-23T17_23_33_473Z-debug.log
I have tried doing the following:
remove the node modules folder and run npm install
remove the node modules and package lock json and do npm install
re install node.js
delete the clone the repository again
I dont get what is wrong. When I look inside the node modules folder the module it is saying is missing is there. This is driving me nuts.

There is a problem when running a node application on ubuntu 18.04

I am trying to run a node site on an azure VM but I get this error when running > SkyCrypt#1.0.0 start
> node init && node index
internal/modules/cjs/loader.js:1109
throw err;
^
SyntaxError: /home/nim1com/SkyCrypt/credentials.json: Unexpected token v in JSON at position 216
at parse (<anonymous>)
at Object.Module._extensions..json (internal/modules/cjs/loader.js:1106:22)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/nim1com/SkyCrypt/init.js:15:21)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! SkyCrypt#1.0.0 start: `node init && node index`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the SkyCrypt#1.0.0 start 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/nim1com/.npm/_logs/2021-01-19T09_41_40_472Z-debug.log```
What would be the answer to this problem? I have tried deleting package-lock.json and node_modules
credentials.json
{
"hypixel_api_key": "26ed366f-80ed-4b49-b912-ef46292c6225",
"recaptcha_site_key": "",
"recaptcha_secret_key": "",
"dbUrl": "mongodb+srv://dbStats:*********#cluster0.4kwsp.mongodb.net/test?retryWrites=true&w=majority",
"dbName": vmstats",
"session_secret": "36e47c144b9b9b3e0b9c8bf24c6ac2860c0f76a55b74dcea4007bf355af76789"
}
It seems your /home/nim1com/SkyCrypt/credentials.json file need to be corrected ...
read the error its complaining about the v in "dbName": vmstats", because is not valid json – Lawrence Cherone

NPM Module triggering a "SyntaxError: Unexpected token ..."! How do I fix it?

My app was working just a short while ago until I merged the master branch. Then all of a sudden I started to get the following errors:
> #COMPANY/MY_APP#1.0.5 storybook /Users/THINKBONOBO/Workspace/MY_APP
> start-storybook -p 9001 -c .storybook
/Users/THINKBONOBO/Workspace/MY_APP/node_modules/generate-page-webpack-plugin/index.js:39
...acc,
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
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)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/THINKBONOBO/Workspace/MY_APP/node_modules/#storybook/core/dist/server/config/webpack.config.prod.js:18:57)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! #COMPANY/MY_APP#1.0.5 storybook: `start-storybook -p 9999 -c .storybook`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the #COMPANY/MY_APP#1.0.5 storybook script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
The error is from some imported public package and it seems it's written in ES6 and all of a sudden my app can't read it.
I tried clearing the cache, node_modules folder, restarting my computer, cloning to a different folder... All to no avail.
What's going on?
The way I fixed this issue was that I updated my node version.
I was running 8.1.1 and updated it with brew (I originally installed node using brew)
brew update ; brew upgrade node
it upgraded to node v 10.10.0 and I was all set.
here's an article on how to update node js on a mac:
https://bytearcher.com/articles/ways-to-get-the-latest-node.js-version-on-a-mac/

Resources