`npm ERR! code 1` after SyntaxError when running `npm ci && npm run build`
Asked Answered
A

1

3

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.

Allergen answered 22/12, 2021 at 19:52 Comment(0)
A
1

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

Allergen answered 23/12, 2021 at 21:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.