简体   繁体   English

我无法在ubuntu16.04上运行nodejs

[英]I can not run nodejs on ubuntu16.04

I have installed nodejs on my ubuntu16.04 . 我已经在ubuntu16.04上安装了nodejs。 But I can't run this. 但是我不能运行这个。 When I write a command npm run dev it shows the following error: 当我编写命令npm run dev时,它显示以下错误:


> @ dev /var/www/html/laravel
> node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

module.js:472
    throw err;
    ^

Error: Cannot find module '/var/www/html/laravel/node_modules/cross-env/bin/cross-env.js'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:425:7)
    at startup (bootstrap_node.js:146:9)
    at bootstrap_node.js:540:3

npm ERR! Linux 4.4.0-66-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
npm ERR! node v7.7.3
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! @ dev: `node node_modules/cross-env/bin/cross-env.js 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 @ dev script 'node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs 
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls 
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/html/laravel/npm-debug.log

Here I have also installed npm-debug .log using the below command but still I'm facing this problem 在这里,我还使用以下命令安装了npm-debug .log,但仍然遇到此问题

npm install --save debug-log enter image description here npm install --save debug-log 在此处输入映像描述

Using npm install installs the module into the current directory only (in a subdirectory called node_modules). 使用npm install将模块安装到当前目录(在名为node_modules的子目录中)。

This guide was very helpful to me as well: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04 该指南对我也非常有帮助: https : //www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04

It's a problem in the package.json "scripts" configuration. 这是package.json“脚本”配置中的问题。 Either replace the "scripts" section in your package.json file with the following: 用以下内容替换package.json文件中的“脚本”部分:

"dev": "cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "cross-env NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "cross-env NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "cross-env NODE_ENV=production webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"

Then re-install the node modules. 然后重新安装节点模块。

Or, as another option, follow Jeffrey Way's advice found at the bottom of the following cross-env issue page . 或者,作为另一个选择,请遵循以下交叉环境问题页面底部的Jeffrey Way的建议。

I had same problem when upgraded cross-env package. 升级跨环境软件包时,我遇到了同样的问题。

Previously it was: 以前是:

node node_modules/cross-env/bin/cross-env.js

I've fixed package.json file and made the path like this: 我已经修复了package.json文件,并使路径如下:

node_modules/cross-env/dist/bin/cross-env.js

And to not happen same issue again I've just set version of cross-env in dependencies to be strict. 为了避免再次发生相同的问题,我只是将cross-env的版本设置为严格。

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

相关问题 ubuntu16.04上的Node.js-无法安装和运行nodemon - Node.js on ubuntu16.04 - Failing to install and run nodemon 无法在ubuntu16.04中的ionic中构建android - Unable to build android in ionic in ubuntu16.04 在 ubuntu 16.04 上更新 nodejs - updating nodejs on ubuntu 16.04 无法访问 google cloud ubuntu 16.04 实例上的 nodeJS REST API,但我可以成功 ping 公共 IP - cannot access nodeJS REST API on google cloud ubuntu 16.04 instance but I can ping on the public IP successfully Ubuntu 16.04 无法运行 npm 运行/安装/重建 - Ubuntu 16.04 Can not run npm run / install /rebuild 在Linux Ubuntu 16.04上安装Node.js - Installing nodejs on linux ubuntu 16.04 我是Ubuntu的新手,但似乎无法使该Curl命令正常工作。 如何在Ubuntu 16.04上安装nodejs 7.x? - I'm new to Ubuntu and I can't seem to get this Curl command to work. How can I install nodejs 7.x on Ubuntu 16.04? 如何在 Linux Ubuntu 中将 NodeJS 应用程序作为 cronjob 运行? - How can I run a NodeJS Application as cronjob in Linux Ubuntu? NodeJS是如何从ubuntu运行两个服务器文件? - NodeJS is how can I run two server file from ubuntu? 带有Express的Socket.IO将无法使用https连接(Apache2 Ubuntu16.04) - Socket.IO with Express will not connect using https (Apache2 Ubuntu16.04)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM