I want to add a script dev in my package.json.
I tried adding it manually in a text editor, but when I run:
npm run dev
I get some errors. Is it possible to add the script from the terminal?
Edit:
I added:
"scripts:" {
"start": "node app",
"dev": "nodemon app"
}
and I got this error:
nodemon app sh: nodemon: command not found
npm ERR! code ELIFECYCLE npm ERR! syscall spawn
npm ERR! file sh npm ERR! errno ENOENT
npm ERR! code#1.0.0 dev: nodemon app npm ERR! spawn ENOENT
npm ERR! npm ERR! Failed at the code#1.0.0 dev script.
The problem here is you have not installed the package named nodemon:
In your CLI enter the following command to install the package:
npm install nodemon --save-dev
Then run the following command and it will work:
npm run dev
Related
I have written a command line utility in JS which can be used to backup data to IPFS.
https://www.npmjs.com/package/ipfs-backup
When I am attempting to install it with npm install -g ipfs-backup I am getting an error which prevents the package from being installed.
The terminal is outputting the following:
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path C:\Users\jwhit\AppData\Roaming\npm\node_modules\ipfs-backup\node index.js
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, chmod 'C:\Users\jwhit\AppData\Roaming\npm\node_modules\ipfs-backup\node index.js'
npm ERR! enoent This is related to npm not being able to find a file.
The issue turned out to be that within my package.json file I had
"bin": {
"ipfs-backup": "node index.js",
"ipfs-restore": "node restore.js"
}
instead of
"bin": {
"ipfs-backup": "./index.js",
"ipfs-restore": "./restore.js"
}
It installs and functions correctly now.
I have this error message : npm ERR! Linux 5.4.72-microsoft-standard-WSL2 on my terminal when I run npm install. I'm on a vue.js app and I have this message since I installed vuetify.
Here is the whole error message :
npm ERR! Linux 5.4.72-microsoft-standard-WSL2
npm ERR! argv "/home/josephine/.nvm/versions/node/v14.15.0/bin/node" "/home/josephine/.nvm/versions/node/v14.15.0/bin/npm" "install"
npm ERR! node v14.15.0
npm ERR! npm v3.10.10
npm ERR! cb.apply is not a function.
I also cannot install the latest version of npm I think this is related to the problem. (I have this version v3.10.10).
And when I run npm run serve I have this :
> vue-cli-service serve
sh: 1: vue-cli-service: not found
npm ERR! Linux 5.4.72-microsoft-standard-WSL2
npm ERR! argv "/home/josephine/.nvm/versions/node/v14.15.0/bin/node" "/home/josephine/.nvm/versions/node/v14.15.0/bin/npm" "run" "serve"
npm ERR! node v14.15.0
npm ERR! npm v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! my-app#0.1.0 serve: vue-cli-service serve
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the my-app#0.1.0 serve script 'vue-cli-service serve'.
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 my-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! vue-cli-service serve
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs my-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls my-app
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?`.
I have the Vue.JS version # vue / cli 4.5.12.
At last, I have a Window PC and I have installed linux and ubuntu.
I thank you in advance if you can help me.
Your npm version is outdated. Your version is 3.x but we're currently at 7.x
Run
npm update -g
and then try again.
PS C:\Users\USER\Desktop\react> npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\USER\Desktop\react\package.json
npm ERR! errno -4058
'C:\Users\USER\Desktop\react\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USER\AppData\Roaming\npm-cache_logs\2020-10-15T10_23_32_090Z-debug.log
It looks like you're trying to run an npm script such as "npm start" in a folder that doesn't have a "package.json" file. Make sure you are in your React project's working directory and try again.
I have a node js app deployed at elasticbeanstalk. Installed and symlinked node, npm and webpack. But when running npm run build-prod which itself calls the script webpack --config /var/app/current/webpack.prod.config.js. Getting the following error with exit status -2. The same happens if I run the webpack command directly too. I'm looking out for solutions.
[2016-07-26T06:57:36.301Z] INFO [9731] - [Application update app-5c81-160726_122417#24/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_site_web/Command 06_npm_run_build_prod] : Activity execution failed, because:
> site-web#1.0.0 build-prod /tmp/deployment/application
> webpack --config /var/app/current/webpack.prod.config.js
npm ERR! Linux 4.4.14-24.50.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v4.4.6-linux-x64/bin/node" "/bin/npm" "run" "build-prod"
npm ERR! node v4.4.6
npm ERR! npm v2.15.5
npm ERR! file sh
npm ERR! path sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn sh
npm ERR! site-web#1.0.0 build-prod: `webpack --config /var/app/current/webpack.prod.config.js`
npm ERR! spawn sh ENOENT
npm ERR!
npm ERR! Failed at the site-web#1.0.0 build-prod script 'webpack --config /var/app/current/webpack.prod.config.js'.
npm ERR! This is most likely a problem with the site-web package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack --config /var/app/current/webpack.prod.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs site-web
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls site-web
npm ERR! There is likely additional logging output above.
npm ERR! Linux 4.4.14-24.50.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v4.4.6-linux-x64/bin/node" "/bin/npm" "run" "build-prod"
npm ERR! node v4.4.6
npm ERR! npm v2.15.5
npm ERR! code ELIFECYCLE
container config file:
container_commands:
01_node_symlink:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node"
02_npm_symlink:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /bin/npm"
03_npm_install_global_packages:
command: "npm install webpack webpack-cli -g"
04_webpack_symlink:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/webpack /bin/webpack"
#05_webpack_run_build_prod:
#command: "webpack --config /var/app/current/webpack.prod.config.js --progress --colors"
06_npm_run_build_prod:
command: "npm run build-prod"
Scripts in package.json
"scripts": {
"build": "webpack --config webpack.local.config.js --progress --colors",
"build-local": "webpack --config webpack.prod.config.js --progress --colors",
"build-prod": "webpack --config /var/app/current/webpack.prod.config.js",
"server": "node app.js",
"dev-server": "node dev-app.js"
}
And when I uncomment 05 that is run the webpack command directly it ends with error Error: "/var/app/current/site-web/static/assets/app/index.js" is not in the SourceMap.
The build script is successful at local but blocked on all the ways at production. Couldn't figure out how to run webpack command to build the JS on AWS beanstalk environment. Isn't the ideal way of building the JS file?
node: 4.4.6
npm: 2.15.5
webpack: latest
I'm still new to elastic beanstalk and having similar issues myself but I noticed your tasks for symlinking node, npm, etc, are in the form of container_commands.
According to the official docs, "They run after the application and web server have been set up and the application version file has been extracted, but before the application version is deployed."
Maybe try using commands: instead of container_commands:. See link I shared.
Maybe the fact that these commands aren't running until after the application and web server have already been set up is why it may not be working for you?
Again, I'm still new to elastic beanstalk but maybe that can help.
I think the approach is faulty. Webpack and Webpack-cli are devDependencies of package.json.
You should set your env variable to NPM_USE_PRODUCTION=false in order for EB to install devDependencies as well.
see more here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/nodejs-platform-packagejson.html
I had issues with global npm installs (in my case react-scripts). What I did as a workaround was to install the dependent package as declared in package.json and then symlink to it (located at /tmp/deployment/application/node_modules/.bin on EC2) in the .ebextensions config file:
03_react_scripts_symlink:
command: "ln -sf /tmp/deployment/application/node_modules/.bin/react-scripts /bin/react-scripts"
04_npm_run_build_prod:
command: "sudo npm run build"
Finally, I managed to run the build script at the staging dir. It's not a permanent solution but it works.
05_webpack_run_build_prod:
command: "cd /tmp/deployment/application && sudo webpack --config webpack.prod.config.js --progress --colors"
I downloaded AngularJS phonecat standard app, and installed Node. But when I move to directory with code and try 'npm start' I get the following error:
> angular-phonecat#0.0.0 start /Users/marya/JS:HTML:CSS/angular-phonecat
> http-server -a 0.0.0.0 -p 8000
sh: http-server: command not found
npm ERR! Darwin 13.4.0
npm ERR! argv "node" "/usr/local/Cellar/nvm/0.17.2/v0.10.32/bin/npm" "start"
npm ERR! node v0.10.32
npm ERR! npm v2.1.4
npm ERR! code ELIFECYCLE
npm ERR! angular-phonecat#0.0.0 start: `http-server -a 0.0.0.0 -p 8000`
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the angular-phonecat#0.0.0 start script.
npm ERR! This is most likely a problem with the angular-phonecat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! http-server -a 0.0.0.0 -p 8000
npm ERR! You can get their info via:
npm ERR! npm owner ls angular-phonecat
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/marya/JS:HTML:CSS/angular-phonecat/npm-debug.log
What does it mean? How can I fix it? Thanks in advance.
Well it does seem like you haven't installed the http-server package.
Try the line below. It should work if it is included in your package.json
$ npm install
otherwise try:
$ npm install http-server