简体   繁体   English

npm 错误在 Laravel 7 运行时 npm 运行开发

[英]npm error in Laravel 7 when running npm run dev

I use Windows 10. I just installed Laravel 7 and I created a new project using the following command:我使用 Windows 10。我刚刚安装了 Laravel 7 并使用以下命令创建了一个新项目:

composer create-project --prefer-dist laravel/laravel briscola

Then I added the following code in app.scss file to render a red background:然后我在 app.scss 文件中添加了以下代码来渲染红色背景:

body {
    background-color: red;
}

Then I run the following code to use the current app.scss file:然后我运行以下代码来使用当前的 app.scss 文件:

npm run dev

However unfortunately the previous command didn't work and I saw the following error:但是不幸的是,前面的命令不起作用,我看到了以下错误:

> @ dev C:\xampp\htdocs\briscola
> npm run development

npm WARN invalid config loglevel="notice"

> @ development C:\xampp\htdocs\briscola
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

"cross-env" non è riconosciuto come comando interno o esterno,
 un programma eseguibile o un file batch.
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 WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Della Mea Michele\AppData\Roaming\npm-cache\_logs\2020-04-05T15_14_25_432Z-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 WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Della Mea Michele\AppData\Roaming\npm-cache\_logs\2020-04-05T15_14_26_197Z-debug.log

Have you any idea about this error and how to solve it?您对这个错误以及如何解决它有任何想法吗?

actually try this,实际试试这个

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

Then然后

npm install cross-env

npm install 

Finally最后

npm run dev

To run npm run dev You should run this command first:要运行npm run dev你应该先运行这个命令:

npm install

If any error appears then you should install Node.js first.如果出现任何错误,则应先安装Node.js

Hope it helps:)希望能帮助到你:)

I did all the accepted answers in this thread (and other threads too) but to no avail.我在这个线程(以及其他线程)中做了所有接受的答案,但无济于事。 What really solved my problem regarding this issue was:真正解决我关于这个问题的问题是:

  1. Uninstall my node.js卸载我的 node.js
  2. Manually delete all npm and node_modules folder in my C:\Program Files (or wherever you might have installed it because ' uninstalling ' sometimes won't delete data folders)手动删除我的 C:\Program Files 中的所有 npm 和 node_modules 文件夹(或您可能安装它的任何位置,因为“卸载”有时不会删除数据文件夹)
  3. Made sure I removed the file path C:\Users\ACER\AppData\Roaming\npm on my Environment Variables确保我删除了环境变量上的文件路径 C:\Users\ACER\AppData\Roaming\npm
  4. Downloaded this node version for my Windows 7 LINK HERE then installed it freshly.为我的 Windows 7链接下载了此节点版本,然后重新安装。 Important: Don't forget to restart your computer after the installation!重要提示:安装后不要忘记重新启动计算机!

These steps were successful and you can try it if above answers don't work.这些步骤是成功的,如果上述答案不起作用,您可以尝试一下。

Now when I rechecked my versions, they are now fine and working and won't give errors.现在,当我重新检查我的版本时,它们现在可以正常工作并且不会出错。

$ npm -v
6.13.4

$ node -v
v13.6.0

$ npx -v
6.13.4

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

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