简体   繁体   English

我尝试在终端中执行 npm run dev 命令时出现 Npm 错误

[英]Npm Error while i try to execute npm run dev command in my terminal

I am a fresher and started my career just 4 months back.我是一名新生,在 4 个月前开始了我的职业生涯。

I am using Ubuntu and laravel for the development of my project.I am trying to compile a .js file for which i installed npm and bower in my project folder.我正在使用 Ubuntu 和 laravel 来开发我的项目。我正在尝试编译一个 .js 文件,我在我的项目文件夹中为该文件安装了 npm 和 bower。 Installation was smooth and is complete.安装顺利完成。

But while executing the "npm run dev" i am getting the below error.但是在执行“npm run dev”时,我收到以下错误。

I executed the below command :我执行了以下命令:

sudo n latest And the error is : sudo n latest 而错误是:

npm run 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

events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: spawn node_modules/webpack/bin/webpack.js ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
    at onErrorNT (internal/child_process.js:407:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:696:3)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12)
    at onErrorNT (internal/child_process.js:407:16)
    [... lines matching original stack trace ...]
    at bootstrapNodeJSCore (internal/bootstrap/node.js:696:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
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 1
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!     /home/vidya/.npm/_logs/2018-09-18T09_27_31_491Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
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!     /home/vidya/.npm/_logs/2018-09-18T09_27_31_546Z-debug.log

Any help on this would be highly appreciated .对此的任何帮助将不胜感激。

NPM version:6.4.1
bower version: 1.8.4
ubuntu version:UBUNTU 16.04 LTS

Steps To Reproduce:重现步骤:

Clean Laravel Installation ( composer create-project laravel/laravel webinterface)清洁 Laravel 安装( composer create-project laravel/laravel webinterface )

run: composer install
run: npm install
run: npm run dev

Follow these steps:按着这些次序:

rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

Here is the link .这是链接

I used the below code in my root and the issue got fixed.我在我的根目录中使用了以下代码,问题得到了解决。

sudo npm install -g PACKAGE-NAME --unsafe-perm=false --allow-root

I used below to install all the packages.我用下面来安装所有的包。

sudo npm install -g --unsafe-perm=false --allow-root 

Npm is working fine now. Npm 现在工作正常。

Thanks for all your help.感谢你的帮助。

应该将 webpack-dev-server 降级为:

npm install --save-dev webpack-dev-server@2.9.7

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM