menu
Channels
# All channels
view-forward
# General
view-forward
# Announcements
view-forward
# Feedback
view-forward
# Guides
view-forward
# I Made This
view-forward
Team

Error on npm run dev

March 21, 2020 at 5:00am

Error on npm run dev

March 21, 2020 at 5:00am (Edited 5 months ago)
I'm trying a website generated with next.js and simple analytics. After running npm install, I ran npm run dev and got the following output:
> [email protected] dev /Users/aidan.steele/Downloads/divjoy-project
> next dev
[ wait ] starting the development server ...
[ info ] waiting on http://localhost:3000 ...
[ error ] ./src/util/analytics.js
Module not found: Can't resolve 'analytics-plugin-simple-analytics' in '/Users/aidan.steele/Downloads/divjoy-project/src/util'
Is this a known issue?
EDIT:
A temporary workaround was to just comment out that import line as it's not yet used. However, when I run npm run build I get the following output:
> [email protected] build /Users/aidan.steele/Downloads/divjoy-project
> next build
Creating an optimized production build
Failed to compile.
./src/util/contact.js
SyntaxError: /Users/aidan.steele/Downloads/divjoy-project/src/util/contact.js: Invalid regular expression flag (2:21)
1 | function submit(data) {
> 2 | return fetch(/api/accnott, {
| ^
3 | method: "POST",
4 | headers: {
5 | "Content-Type": "application/json"
> Build error occurred
Error: > Build failed because of webpack errors
at build (/Users/aidan.steele/Downloads/divjoy-project/node_modules/next/dist/build/index.js:12:900)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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! /Users/aidan.steele/.npm/_logs/2020-03-21T05_03_27_601Z-debug.log
It looks like that first argument to fetch should be a string?

March 21, 2020 at 5:23pm
Hey Aidan, thanks for bringing this to my attention. Both those issues are bugs and I'm deploying a fix right now. All you need to do is change the Simple Analytics import to import simpleAnalyticsPlugin from '/simple-analytics'
Edited
  • reply
  • like
And in contact.js it should be "/api/contact" (so a string like you suggested)
  • reply
  • like