weixin_39715513
weixin_39715513
2021-01-11 06:55

npm run watch error

  • Laravel Mix Version: 0.10.0 (npm list --depth=0)
  • Node Version 6.9.5 (node -v):
  • NPM Version 3.10.10(npm -v):
  • OS: Windows (using laravel homestead)

Description:

I've read a lot about this, but I've tried everything so far and it doesn't help with my issue. I'm just starting with Vue and I wanted to make sure that my js changes were being compiled. I added some text to Example.vue and ran the following command:

sudo npm run watch

Now the component doesn't show on my page and I get the following output:

bronze.0.0 watch /home/vagrant/Code/bronze node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

10% building modules 2/2 modules 0 active Webpack is watching the files… 95% emitting
ERROR Failed to compile with 1 errors

This dependency was not found:

  • /home/vagrant/Code/bronze/resources/assets/sass/app.scss in multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

To install it, you can run: npm install --save /home/vagrant/Code/bronze/resources/assets/sass/app.scs Asset Size Chunks Chunk Names /js/app.js 1.21 MB 0 [emitted] [big] /js/app mix-manifest.json 32 bytes [emitted]

Steps To Reproduce:

该提问来源于开源项目:JeffreyWay/laravel-mix

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

7条回答

  • weixin_39760857 weixin_39760857 3月前

    I had this occasionally after (I suspect) using Yarn Add to add some packages while otherwise using npm install / npm run. After running npm install again, everything worked fine again. My setup: - node version 9.4.0, - Laravel 5.6 with Mix

    点赞 评论 复制链接分享
  • weixin_39723010 weixin_39723010 3月前

    Can you paste in your webpack.mix.js file?

    点赞 评论 复制链接分享
  • weixin_39826984 weixin_39826984 3月前

    I am also having this same problem with the standalone version of Laravel Mix.

    I have this directory structure:

    
    assets/
        /dist
            /js
                /vendor
                    plugins.js
            app.js
            /css
        /src ..
    
    

    Here is my webpack.mix.js file:

    
    mix.js('assets/src/js/app.js', 'assets/dist/js/')
        .js('assets/src/js/vendor/webgazer.js', 'assets/dist/js/vendor/')
        .sass('assets/src/scss/app.scss', 'assets/dist/css/');
    

    When I run npm run watch on the first run it works just fine... when I make a change to any SCSS or JS file the /dist/js directory gets cleared of any files that were created on the initial run. My SCSS files work just like they should.

    Am I missing something here?

    点赞 评论 复制链接分享
  • weixin_39601194 weixin_39601194 3月前

    ~~Having the same issue, here. Any help on this one?~~

    Edit: Updating node fixed my issue. I used Homebrew, so to update I ran brew upgrade node. All good!

    点赞 评论 复制链接分享
  • weixin_39614657 weixin_39614657 3月前

    Hi JeffreyWay

    I have a similar issue.

    npm run dev

    @ dev /Users/ramsey/portfolio/pm_laravel npm run development

    @ development /Users/ramsey/portfolio/pm_laravel cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

    95% emitting

    ERROR Failed to compile with 2 errors 15:47:46

    These dependencies were not found:

    • /Users/ramsey/portfolio/pm_laravel/resources/assets/js/app.js in multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss
    • /Users/ramsey/portfolio/pm_laravel/resources/assets/sass/app.scss in multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

    To install them, you can run: npm install --save /Users/ramsey/portfolio/pm_laravel/resources/assets/js/app.js /Users/ramsey/portfolio/pm_laravel/resources/assets/sass/app.scss Asset Size Chunks Chunk Names /js/app.js 2.95 kB 0 [emitted] /js/app mix-manifest.json 32 bytes [emitted]
    npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! @ development: cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the @ development 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/jiangdawei/.npm/_logs/2017-07-13T03_47_46_870Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! @ dev: npm run development npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the @ dev 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/jiangdawei/.npm/_logs/2017-07-13T03_47_46_894Z-debug.log

    My package.json is

    { "private": true, "scripts": { "dev": "npm run development", "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "watch-poll": "npm run watch -- --watch-poll", "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", "prod": "npm run production", "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" }, "devDependencies": { "axios": "^0.16.2", "bootstrap-sass": "^3.3.7", "cross-env": "^5.0.1", "jquery": "^3.1.1", "laravel-mix": "1.0", "lodash": "^4.17.4", "vue": "^2.1.10", "vue-router": "^2.7.0" } }

    My webpack.mix.js is: let mix= require('laravel-mix');

    mix.js('resources/assets/js/app.js', 'public/js') .sass('resources/assets/sass/app.scss', 'public/css');

    Please help me. Thank you so much.

    Now npm run dev and npm run watch don't work.

    点赞 评论 复制链接分享
  • weixin_39723010 weixin_39723010 3月前

    It's an npm 5.2 issue. I bet you have that new version installed. Downgrade until they release the patch.

    点赞 评论 复制链接分享
  • weixin_39614657 weixin_39614657 3月前

    Do you know which version works?

    点赞 评论 复制链接分享