question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

npm run watch .js error file

See original GitHub issue

When I run command “npm run watch” or “npm run watch-poll”, the script generates a bugged .js file, and the browser console shows “Uncaught SyntaxError: Invalid or unexpected token”.

If I try to open the js file with Sublime Text (Finder show me Zero KB), seems that the script falls in a never ending loop writing in the js file null and after the compiled js script, null and so on…

No problem running the “npm run watch” with only the scss files or, with the js, running “npm run dev”.

Here’s my configs:

Node: 8.1.4 NPM: 5.5.1 Laravel mix: 1.5.0

Webpack.mix.js:

const {mix} = require('laravel-mix');
const dotenv = require('dotenv-webpack');

mix.webpackConfig({
    plugins: [
        new dotenv({
            path: './.env', // Path to .env file (this is the default)
            safe: true // load .env.example (defaults to "false" which does not use dotenv-safe)
        })
    ]
})
    .js('./resources/assets/javascripts/app.js', './public/assets/javascripts/web.min.js')
    .sass('./resources/assets/stylesheets/main.scss', './public/assets/stylesheets/main.min.css')
    .scripts([
            './public/assets/javascripts/web.min.js',
            './node_modules/jquery-migrate/dist/jquery-migrate.min.js',
            './node_modules/jquery.stellar/jquery.stellar.js'
        ], './public/assets/javascripts/web.min.js'
    )
    .extract([
        'axios',
        'jquery',
        'lodash',
        'vue'
    ]);

HELP ME!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
ItsLhoudinicommented, Oct 18, 2017

WORKS FINE! Thanx

1reaction
artemskycommented, Oct 17, 2017

why you trying to pack your output script. web.min.js it’s not valid code, you shouldn’t do that

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm run watch .js error file · Issue #1278 - GitHub
When I run command "npm run watch" or "npm run watch-poll", the script generates a bugged .js file, and the browser console shows...
Read more >
Laravel NPM error "npm run watch " in command line
Laravel's mix.js() takes at least one parameter. In the project root directory look at webpack.mix.js file, and then check mix.js().
Read more >
Npm run watch displays error after compiling then stops ...
Most of the time this error means that you have to wrong file permissions on your assets. Make sure they all have the...
Read more >
npm-watch
Run scripts from package.json when files change. Common Issues. monorepo setups : In a monorepo setup, npm-watch may fail ...
Read more >
How To Fix “Laravel Mix NPM run dev error” - YouTube
This video will help you to solve the annoying “Laravel Mix NPM run dev error ” that you probably have seen before when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found